I use the system.timers.timer for my service.
Now I build a test-form in which I use it too. In the timer_Elapsed Event I do some work and want to stop the timer it
When using System.Timers.Timer, Use the SynchronizingObject Property of the timer. Apparently this causes the method that handles the Elapsed event to be called on the same thread that the assigned component (SynchronizingObject) was created on.
eg. if myButton is a control on your form (whatever main GUI thread),
System.Timers.Timer myTimer = new System.Timers.Timer();
myTimer.SynchronizingObject = this.myButton;
this causes the Elapsed handler to run on the same thread , removes some 'cross thread operation' errors.
Pls Note: I have very little knowledge on whether this is thread safe, but worked fine for me in a Specific use case. Hope it helps anyway.