I have a scenario as follow in Windows Product based application using .net 4.
1. A VB.NET project consists of one usercontrol with a few controls in it.
2. I load this control (once or many) times on the main form as in Me.Controls.Add(usercontrol)
3. The project has a timer which updates a label control in the usercontrol for every tick (every 1000 ms) which gets initiated in the Main form
4. I do also have a button on the main form with a separate task say Thread.Sleep or loop untill the elapsed time using stopwatch crosses 5000 ms and then comes out of the button click event
5. Now When I click this button my control which is getting updated by a timer in the usercontrol ALSO stops untill the button click event completes. It is as if the entire application gets suspended for a while (5 secs).
NOW I would need the timer control to update the label control in the usercontrol IRRESPECTIVE of any process that is running through the main form.
I would need a seamless update to the label in the user control.
I have tried with multiple threads et al. Nevertheless whenver the main form or the main thread does some job then the other controls say a timer update etc...stops for a while until the main form is free.
I would like to know how to keep updating the label control in the user control (say a timer updates the elapsed time in the label control) even when I click the button from the main form which does a loop for 5 seconds etc....
Please do let me know how to go about it.