Created
October 6, 2015 20:53
-
-
Save i3arnon/2e0514dda69a589631a8 to your computer and use it in GitHub Desktop.
Timer.Change takes a lock on a singleton instance.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal bool Change(uint dueTime, uint period) | |
{ | |
bool success; | |
lock (TimerQueue.Instance) | |
{ | |
if (m_canceled) | |
throw new ObjectDisposedException(null, Environment.GetResourceString("ObjectDisposed_Generic")); | |
// prevent ThreadAbort while updating state | |
try { } | |
finally | |
{ | |
m_period = period; | |
if (dueTime == Timeout.UnsignedInfinite) | |
{ | |
TimerQueue.Instance.DeleteTimer(this); | |
success = true; | |
} | |
else | |
{ | |
if (FrameworkEventSource.IsInitialized && FrameworkEventSource.Log.IsEnabled(EventLevel.Informational, FrameworkEventSource.Keywords.ThreadTransfer)) | |
FrameworkEventSource.Log.ThreadTransferSendObj(this, 1, string.Empty, true); | |
success = TimerQueue.Instance.UpdateTimer(this, dueTime, period); | |
} | |
} | |
} | |
return success; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment