views:

138

answers:

3

I have a WinForm app(.net 3.5) that when you first select a Person it retrieves all of that persons data for there entire Plan. This can take up to 5 secs. I need to show my users(in house only) that the program is loading/working in some way. I also need to keep them at that screen until it finishes as well. Do to the design of the app they could jump to any number of places in the App.

I thought maybe a Background Worker is what I want but because I want them to stay where they are until it loads I am no longer sure(???).

What my App is doing is populating ~ 20 User Controls. Each User Control queries a Local SQL Express DB for it's information. So I have a method on my Parent Form that goes through and 'Paints' all the User Controls and that is what they are waiting for.

Ideas? What's my best bet.

+2  A: 

BackgroundWorker is a sound choice, go for it - it's designed for scenarios such as you describe.

Aviad P.
I could just have the back ground worker pop up a progress indicator and that would keep them there?
Refracted Paladin
That's one way of doing it, having a modal dialog open until the background worker finishes.
Aviad P.
That's the wrong way of doing it. Your UI is still dead, the form's caption will change to "Not Responding". The BGW must do the heavy lifting.
Hans Passant
A: 

How about a locked modal window with a progressbar that changes on events thrown by the backgroundworker? Winforms isn't really my bag but something like this could work.

magnus
+1  A: 

You could create a ProgressBarForm that has a progress bar. Do a ShowDialog to make it modal.

And subscribe to the ReportProgress of the BackgroundWorker to make your progress bar progress.

pdiddy