System.Threading.Timer. API:
If periodis zero (0) or Timeout.Infinite and dueTimeis not Timeout.Infinite, callbackis invoked once [...]
Ergo, a single shot timer can be created such as
Timer oneShotTimer = new Timer((object stateInfo) => {
}, null, yourOneShotTimePeriodHere, Timeout.Infinite);
The API also has a trick to get rid of a timer from its callback method: fooobar.com/questions/1342785 / ...
source
share