I am developing an application which makes the search request via the web service. Meanwhile the progress bar control is displayed to the user.
Now, I am using a timer to update the progress bar.
As far as I know, the System.Timer should start in the new thread... and here I am having a problem...
Start the timer:
And when timer elapsed, I want to update my progress bar.
The progress bar owner is the main UI thread, but the event is raised in the timer thread. So I can't call in cpProgressBar_update method just this.progressBar.PerformStep(). Am I right?
Should I use Invoke() methods in the raised event? I have tried different solutions I have thought about, but the results weren't what I had expected...
Now, I am using a timer to update the progress bar.
As far as I know, the System.Timer should start in the new thread... and here I am having a problem...
Start the timer:
Code:
this.timer.Interval = 100;
this.timer.Elapsed += new System.Timers.ElapsedEventHandler(this.cbProgressBar_update);
this.timer.Start();
And when timer elapsed, I want to update my progress bar.
The progress bar owner is the main UI thread, but the event is raised in the timer thread. So I can't call in cpProgressBar_update method just this.progressBar.PerformStep(). Am I right?
Should I use Invoke() methods in the raised event? I have tried different solutions I have thought about, but the results weren't what I had expected...