Ive an application that needs to poll 3 seperate message queues, and so the thinking is that I should just allocate 3 timers, and set each one with a delegate to trigger each time the timer is completed.
This has got me thinking,
When the delegate is fired, does it exist in the same thread as the calling code, or does it temporarily spawn a new thread to execute in, before returning back to the main code thread.
If the delegates all fire in the main thread and stay there, then what will happen when timer ones delegate is firing, and Timer two's is triggered. Does Timer 2 wait, or does it pause Timer 1s operation temporarily?
Logic tells me that as you may not have stopped the timer, the OnTimerComplete event should execute in its own thread to prevent the timers clashing, but as this is a critical piece of code I'd rather not assume anything. (And as 2 of the timer complete event handlers need access to some of the same objects, I need to know if I have to write code to prevent them clashing)
Cheers
K
This has got me thinking,
When the delegate is fired, does it exist in the same thread as the calling code, or does it temporarily spawn a new thread to execute in, before returning back to the main code thread.
If the delegates all fire in the main thread and stay there, then what will happen when timer ones delegate is firing, and Timer two's is triggered. Does Timer 2 wait, or does it pause Timer 1s operation temporarily?
Logic tells me that as you may not have stopped the timer, the OnTimerComplete event should execute in its own thread to prevent the timers clashing, but as this is a critical piece of code I'd rather not assume anything. (And as 2 of the timer complete event handlers need access to some of the same objects, I need to know if I have to write code to prevent them clashing)
Cheers
K