I donβt know if DispatchTimer has any smart way to do this, but what I will do in this situation is not to try to force the timer not to fire the event, but to prevent the event from doing anything if it did not complete the previous run.
You can use locks for this by getting a lock at the beginning of the event handler. If the lock is not available, exit the function (it is already running), if you close the lock, and then, as soon as you finish work, start the lock.
You want Monitor.TryEnter , and you want to make sure that you are correctly mistaken, as with any locks.
Chris source share