I have developed an application and i want to add a Datetime (digital clock) indicator on the Mdi form. But i want this indicator to be active whenever my application has delays due to long query results. I used a timer and i updated my datetime indicator label in the timer1_tick event.
So what i'm basically looking for is, a form which shows the time (hh:mm:ss). And the time should not freeze if i click a button which loops 10,000,000 times. I know i can do that by making the loop in another thread but i don't want it that way. I would rather have the loop begin using a button_click event with the main thread and have another thread which updates my date time indicator label every second.
So, to give u a short and precise meaning of what i want.
1. A form which has a button to start a long time consuming for loop like say 10,000,000 and label which shows the loop has ended.
2. A timer to start with the form_load event in another thread and show me the time before i even click the loop button.
3. This timer should have an interval of 1000 (1 second) and should update the datetime indicator label which shows the value of the DateTime.Now value.
4. When i start the loop button, i want to the timer to continue ticking thus updating the datetime indicator label.
so you can say what i'm looking for is an application which has 2 threads who start together, where the second thread has a timer which updates a label every second no matter what happens on the first thread.
I would greatly appreciate it if you can attach the solution or source code so that i can download it and use it. I use C# in Visual studio 2008.
Thank you very much.