public void Stop()
{
#region Require
if (disposed)
{
throw new ObjectDisposedException("Timer");
}
#endregion
#region Guard
if (!running)
{
return;
}
#endregion
// Stop and destroy timer.
int result = timeKillEvent(timerID);
Debug.Assert(result == TIMERR_NOERROR);
running = false;
if (IsAsync)
{
Task.Factory.StartNew(() => OnStopped(new EventArgs()));
}
else
{
OnStopped(EventArgs.Empty);
}
}