Refracted Paladin
Refracted Paladin

Reputation: 12216

Show progress till an operation completes winform

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.

Upvotes: 0

Views: 1480

Answers (3)

pdiddy
pdiddy

Reputation: 6297

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.

Upvotes: 3

magnus
magnus

Reputation: 653

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.

Upvotes: 0

Aviad P.
Aviad P.

Reputation: 32639

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

Upvotes: 2

Related Questions