<Compile Include="$(BclSourcesRoot)\System\Threading\WaitHandle.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\SpinLock.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadLocal.cs" />
- <Compile Include="$(BclSourcesRoot)\System\Threading\ManualResetEventSlim.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\CancellationTokenRegistration.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\CancellationTokenSource.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\future.cs" />
/// </exception>
/// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="timeout"/> is a negative
/// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater
- /// than <see cref="System.int.MaxValue"/> milliseconds.
+ /// than <see cref="System.Int32.MaxValue"/> milliseconds.
/// </exception>
public void TryEnter(TimeSpan timeout, ref bool lockTaken)
{
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout"/> is a negative number other than -1 milliseconds, which represents an
/// infinite time-out -or- timeout is greater than
- /// <see cref="System.int.MaxValue"/>.
+ /// <see cref="System.Int32.MaxValue"/>.
/// </exception>
public bool Wait(TimeSpan timeout)
{
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout"/> is a negative number other than -1 milliseconds, which represents an
/// infinite time-out -or- timeout is greater than
- /// <see cref="System.int.MaxValue"/>.
+ /// <see cref="System.Int32.MaxValue"/>.
/// </exception>
[MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger
public static bool WaitAll(Task[] tasks, TimeSpan timeout)
/// <exception cref="T:System.ArgumentOutOfRangeException">
/// <paramref name="timeout"/> is a negative number other than -1 milliseconds, which represents an
/// infinite time-out -or- timeout is greater than
- /// <see cref="System.int.MaxValue"/>.
+ /// <see cref="System.Int32.MaxValue"/>.
/// </exception>
[MethodImpl(MethodImplOptions.NoOptimization)] // this is needed for the parallel debugger
public static int WaitAny(Task[] tasks, TimeSpan timeout)
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LazyThreadSafetyMode.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\LockRecursionException.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ManualResetEvent.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ManualResetEventSlim.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Mutex.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\NativeOverlapped.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ParameterizedThreadStart.cs" />
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#pragma warning disable 0420
-
-// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
-//
-// SlimManualResetEvent.cs
-//
-//
-// An manual-reset event that mixes a little spinning with a true Win32 event.
-//
-// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
using System.Diagnostics;
if (Interlocked.CompareExchange(ref m_eventObj, newEventObj, null) != null)
{
// Someone else set the value due to a race condition. Destroy the garbage event.
- newEventObj.Close();
+ newEventObj.Dispose();
return false;
}
// necessary. However, the coding pattern { event.Wait(); event.Dispose() } is
// quite common, and we must support it. If the waiter woke up and disposed of
// the event object before the setter has finished, however, we would try to set a
- // now-disposed Win32 event. Crash! To deal with this race condition, we use a lock to
+ // now-disposed Win32 event. Crash! To deal with this race condition, we use a lock to
// protect access to the event object when setting and disposing of it. We also
// double-check that the event has not become null in the meantime when in the lock.
/// false.</returns>
/// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="timeout"/> is a negative
/// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater
- /// than <see cref="System.int.MaxValue"/>.</exception>
+ /// than <see cref="System.Int32.MaxValue"/>.</exception>
/// <exception cref="T:System.InvalidOperationException">
/// The maximum number of waiters has been exceeded.
/// </exception>
/// false.</returns>
/// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="timeout"/> is a negative
/// number other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater
- /// than <see cref="System.int.MaxValue"/>.</exception>
+ /// than <see cref="System.Int32.MaxValue"/>.</exception>
/// <exception cref="T:System.Threading.OperationCanceledException"><paramref
/// name="cancellationToken"/> was canceled.</exception>
/// <exception cref="T:System.InvalidOperationException">
// Clean up: we're done waiting.
Waiters = Waiters - 1;
}
-
// Now just loop back around, and the right thing will happen. Either:
// 1. We had a spurious wake-up due to some other wait being canceled via a different cancellationToken (rewait)
// or 2. the wait was successful. (the loop will break)
{
lock (eventObj)
{
- eventObj.Close();
+ eventObj.Dispose();
m_eventObj = null;
}
}
/// <exception cref="ArgumentNullException">The <paramref name="condition"/> argument is null.</exception>
/// <exception cref="T:System.ArgumentOutOfRangeException"><paramref name="timeout"/> is a negative number
/// other than -1 milliseconds, which represents an infinite time-out -or- timeout is greater than
- /// <see cref="System.int.MaxValue"/>.</exception>
+ /// <see cref="System.Int32.MaxValue"/>.</exception>
public static bool SpinUntil(Func<bool> condition, TimeSpan timeout)
{
// Validate the timeout