Last active
October 6, 2015 21:06
-
-
Save i3arnon/376592721ee050c65b35 to your computer and use it in GitHub Desktop.
Timer.Change takes a lock on a singleton instance (http://referencesource.microsoft.com/#mscorlib/system/threading/timer.cs)
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) // Global lock. | |
{ | |
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