Multiple Forms
Hi All
I have two forms that are shown at the same time when my application starts. I have a timer on both forms. Form A has a timer that runs every 20 seconds
Form B has a timer that runs every 100ms.
When Form A timer runs its pauses the timer in Form B until the timer has finished doing its job.
How do I get these timers to run idependantly so that neither of the timers effect each other??
Regards
Djbell
[465 byte] By [
1druid1] at [2007-11-20 8:35:31]

# 2 Re: Multiple Forms
Both forms are executing on the UI thread. The Tick events will be being raised at the correct times, +/- the 55 millisecond accuracy of the Windows.Forms.Timer class. That said, no thread can do two things at once so only one Tick event can be handled at a time. The other event will be queued until the thread is available to process it.
The answer is to process the events on different threads. Instead of using a Windows.Forms.Timer use a Timers.Timer on at least one of the forms. If the SynchronizingObject is set to Nothing the Elapsed event will be raised in a background thread and not interfere directly with the other.
Note that you will have to use delegation to access any controls but that's not hard when you know how. If you need to access controls from both Timers' event handlers then I'd suggest using a Timers.Timer on both forms.