How to implement progress bar and backgroundworker for database calls C#?
- by go-goo-go
How to implement progress bar and backgroundworker for database calls C#?
I do have some methods that deal with large amounts of data. They do last a lot, so in my windows application, i wanna do something to tell users that the data are being processed.
So i thought of using progress bar or status strip label, but since there is a single ui thread, the thread where the database-dealing methods are executed, ui controls are not updated, so progress bar or status strip label are useless to me.
I've already seen some examples, but they deal with for-loops, ex:
for(int i = 0; i < count; i++){
System.Threading.Thread.Sleep(70);
// ... do analysis ...
bgWorker.ReportProgress((100 * i) / count);}
private void bgWorker_ProgressChanged(object sender, ProgressChangedEventArgs e){
progressBar.Value = Math.Min(e.ProgressPercentage, 100);}
Can anybody give an example where I can use a method call, not a for-loop, and let the progress bar run while this method is executing???
thnx in advance, any help and hint is highly appreciated.