There are times in my application, when I need to invoke my timer manually.
I’ve tried the following:
int originalInterval = t.Interval;
t.Interval = 0;
t.Interval = originalInterval;
but it wasn’t consistent.
I’ve created a new timer, inheriting from System.Timers.Timer, and exposed a “Tick” method – but the problem was that the “Elapsed” event then fired synchronously.
When I implemented the “Tick” with a new Thread – the results were, again, not consistent.
Is there a better way to implement it?
I once had the same problem, so I used the AutoResetEvent to know if the Elapsed was invoked successfully: