Imported Upstream version 4.2.1.91

Former-commit-id: 5bd0f48812d39b3636887951adc772b94ef2f5af
This commit is contained in:
Xamarin Public Jenkins
2015-10-30 12:42:46 -04:00
committed by Jo Shields
parent 2faab2dafa
commit f1bb32afc3
48 changed files with 211 additions and 83 deletions

View File

@ -71,7 +71,7 @@ namespace System.Threading
/// actually run the callbacks.
private volatile int m_threadIDExecutingCallbacks = -1;
private bool m_disposed;
private int m_disposed;
private CancellationTokenRegistration [] m_linkingRegistrations; //lazily initialized if required.
@ -134,7 +134,7 @@ namespace System.Threading
/// </summary>
internal bool IsDisposed
{
get { return m_disposed; }
get { return m_disposed == 1; }
}
/// <summary>
@ -573,7 +573,7 @@ namespace System.Threading
// mutates a sparseArrayFragment and then reads from properties of the CTS that are not
// invalidated by cts.Dispose().
if (m_disposed)
if (m_disposed != 0 || Interlocked.CompareExchange (ref m_disposed, 1, 0) != 0)
return;
if (m_timer != null) m_timer.Dispose();
@ -598,8 +598,6 @@ namespace System.Threading
m_kernelEvent.Close(); // the critical cleanup to release an OS handle
m_kernelEvent = null; // free for GC.
}
m_disposed = true;
}
}
@ -613,7 +611,7 @@ namespace System.Threading
#endif
internal void ThrowIfDisposed()
{
if (m_disposed)
if (m_disposed == 1)
ThrowObjectDisposedException();
}