Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6098991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:13:18+00:00 2026-05-23T13:13:18+00:00

I am creating an application using c# and database in webserver.while accessing data from

  • 0

I am creating an application using c# and database in webserver.while accessing data from the webserver ,it is very slow and the form is also gets hanged up until the datas are loaded.Is there a way to load the form first and the datas later ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:13:18+00:00Added an answer on May 23, 2026 at 1:13 pm

    The common way to solve this is to use the BackgroundWorker class.

    public void InitBackgroundWorker()
    {
        backgroundWorker.DoWork += YourLongRunningMethod;
        backgroundWorker.RunWorkerCompleted += UpdateTheWholeUi;
    
        backgroundWorker.WorkerSupportsCancellation = true; // optional
    
        // these are also optional
        backgroundWorker.WorkerReportsProgress = true;
        backgroundWorker.ProgressChanged += UpdateProgressBar;
    }
    
    // This could be in a button click, or simply on form load
    if (!backgroundWorker.IsBusy)
    {
        backgroundWorker.RunWorkerAsync(); // Start doing work on background thread
    }
    
    // ...
    
    private void YourLongRunningMethod(object sender, DoWorkEventArgs e)
    {
        var worker = sender as BackgroundWorker;
    
        if(worker != null)
        {
            // Do work here...
            // possibly in a loop (easier to do checks below if you do)
    
            // Optionally check (while doing work):
            if (worker.CancellationPending == true)
            {
                e.Cancel = true;
                break; // If you were in a loop, you could break out of it here...
            }
            else
            {
                // Optionally update
                worker.ReportProgress(somePercentageAsInt);
            }
    
            e.Result = resultFromCalculations; // Supports any object type...
        }
    }
    
    private void UpdateProgressBar(object sender, ProgressChangedEventArgs e)
    {
        int percent = e.ProgressPercentage;
        // Todo: Update UI
    }
    
    private void UpdateTheWholeUi(object sender, RunWorkerCompletedEventArgs e)
    {
        if (e.Cancelled)
        {
            // Todo: Update UI
        }
        else if (e.Error != null)
        {
            string errorMessage = e.Error.Message;
            // Todo: Update UI
        }
        else
        {
            object result = e.Result;
            // Todo: Cast the result to the correct object type,
            //       and update the UI
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a database application using ASP.NET and I want to make a Windows
Situation I'm creating a C#/WPF 4 application using a SQL Compact Edition database as
I am creating a database application using Visual C# Express and MySQL. The issue
I am creating a C# application using Visual Studio that uses an SQLExpress database.
I'm creating a Windows Form application using C#. The form contains a ListView. It's
I am creating an application in grails that should read from one database and
I've been playing around with creating an application using the S#arp Architecture . One
I am creating a WPF Application using VS 2005. I download the add on
I am just getting started creating an AJAX application using server side push. I
I am part of a team creating a web application using PHP and MySQL.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.