Rajesh Kumar G
Rajesh Kumar G

Reputation: 1534

Windows form hanging problem

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?

Upvotes: 1

Views: 968

Answers (3)

decyclone
decyclone

Reputation: 30840

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.

Upvotes: 0

Darin Dimitrov
Darin Dimitrov

Reputation: 1039498

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

Upvotes: 3

Pabuc
Pabuc

Reputation: 5638

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

Upvotes: 1

Related Questions