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 3873862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:05:08+00:00 2026-05-19T22:05:08+00:00

I have a form that is loading quite an amount of data from SQL

  • 0

I have a form that is loading quite an amount of data from SQL server. Below is the code that will provide a good hint:

private void BranchCenter_Load(object sender, EventArgs e) {
  //Combo boxes:
  LoadCities();
  LoadCoordinators();
  LoadComputerSystems();

  //Actual entity
  LoadBranch();
}

private void LoadCities() {
  //LINQ2SQL to load data. ~5000 records.
}

private void LoadCoordinators() {
  //LINQ2SQL to load data. ~50 records.
}

private void LoadComputerSystems() {
  //LINQ2SQL to load data. ~550 records.
}

private void LoadBranch() {
  LoadBranchInit();
  LoadBranchDetails();
  LoadBranchTimings();
  LoadBranchServices();
  LoadBranchLocumsHistory();
  LoadBranchJobs();
  LoadBranchNotes();
}

private void LoadBranchInit() {
  //LINQ2SQL to load the Branch object based upon the Branch ID
}

private void LoadBranchDetails() {
  //LINQ2SQL to load basic branch stuff. 38 fields. Mixed editors.
}

private void LoadBranchTimings() {
  //LINQ2SQL to load timings info into 80 date-time controls
}

private void LoadBranchServices() {
  //LINQ2SQL to load services offered at branch info into 20 check-boxes controls
}

private void LoadBranchLocumsHistory() {
  //LINQ2SQL to load branch history info into grid control. Always increasing # of rows :(
}

private void LoadBranchJobs() {
  //LINQ2SQL to load branch jobs info into grid control. Always increasing # of rows :( 
}

private void LoadBranchNotes() {
  //LINQ2SQL to load branch notes info into grid control
}

The UI is a form with a tab controls. each detail from above goes to a tab page. I need to load and show the form to user as fast as possible. once the form is shown, i need to launch a series of background workers to get the data for each page.

I have been trying to mess with the background worker but unable to understand it’s usage. I end up getting message of “different thread attempted to access control on your main thread… or something like that…”

The ideal situation would be to have a progress bar loading the data on every tab and the tab becoming inter-actable once the respective background worker finishes.

Any strategy or advice? Thanks for the read.

  • 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-19T22:05:09+00:00Added an answer on May 19, 2026 at 10:05 pm

    Create a BackgroundWorker for each of the tabs. In the Load event of the form, disable all tabs and call the RunWorkerAsync() method for each of the background workers.

    In each DoWork event handler, load the data required for the associated tab page from the database into a data table and set the Result property of the DoWorkEventArgs to the data table.

    Note: In the DoWork event handler you should NOT update any UI control since it is operating in a different thread. You should only retrieve the data from the database and set the Result property.

    In the RunWorkerCompleted event handlers, you can access the data table, that was retrieved in the DoWork event handler, by getting the Result property of the RunWorkerCompletedEventArgs. Then you can set the properties of the UI controls accordingly and then enable the tab page associated with the current background worker.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form that displays several keywords (standard set of choice lists that changes
I have a form that contains a GridView control which is databound to an
I have a form that I would like to style. specifcally I would like
I have a form that searches all rows in a single table (TServices) that
I have a form that is sending in sizes of things, and I need
I have a form that has multiple fields, and for testing purposes is there
I have a form that uses jQuery to submit an ajax post and it
I have a form that excepts a file upload in ASP.NET. I need to
We have a form that allows a user to filter a list with by
I have a form that sits behind ASP.NET forms authentication. So far, the implementation

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.