1

Consider this scenario: I have two forms (Form1 and Form2). When a button is clicked in Form1, it loads Form2. Form2 contains gridcontrol to show some data. Since the data is large, Form2 takes some time to load. That freezes the whole application.

I would like to access Form1 while Form2 is loading. Is it possible?

Vilx-
  • 104,512
  • 87
  • 279
  • 422
Rajesh Kumar G
  • 1,424
  • 5
  • 18
  • 30

3 Answers3

3

You could use a BackgroundWorker to load the data in a separate thread to avoid blocking the main thread.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
1

Yes it is if you load your data in Form2 in a different thread. You can check this page.

Pabuc
  • 5,528
  • 7
  • 37
  • 52
0

Look at this answer for Loading data from DB asynchronously in win forms.

You will have to load data asynchronously to allow form2's UI responsive.

Now to access Form1 from Form2, you could:

  • Pass form1's reference to form2 (not recommended)
  • Create a static class with global members to exchange data.
Community
  • 1
  • 1
decyclone
  • 30,394
  • 6
  • 63
  • 80