final class · System.Threading
AutoResetEvent
public final class AutoResetEvent : ManualResetEvent
An event that lets one waiter through each time it is set (and resets itself).
- Kind
- final class
- Namespace
- System.Threading
- Assembly
- System.Core
- Access
- public, final
- Source file
Threading.ant
Inheritance
- Base classes
-
AnyManualResetEventAutoResetEvent
Constructors
Methods
Inherited members (12)
mutexfield from ManualResetEventchangedfield from ManualResetEventsetfield from ManualResetEventSetmethod from ManualResetEventResetmethod from ManualResetEventDisposemethod from ManualResetEventIsSetproperty from ManualResetEventGetTypemethod from AnyUndescribedmethod from AnyToStringmethod from AnyHashmethod from Anydestroymethod from Any
Source
AutoResetEvent as Antril, decompiled from its Larva HIR.
// System.Threading.AutoResetEvent — System.Core (decompiled from Larva HIR)
import System;
into namespace System.Threading
{
/// An event that lets one waiter through each time it is set (and resets itself).
public final class AutoResetEvent : ManualResetEvent
{
public:
new(bool initialState) : base(initialState)
{
}
override WaitOne()
{
mutex.Lock();
loop (!set)
changed.Wait(mutex);
set = false;
mutex.Unlock();
}
override WaitOne(i32 milliseconds) : bool
{
i64 until = Environment.TickCount64 + (i64)milliseconds;
mutex.Lock();
loop (!set)
{
i64 left = until - Environment.TickCount64;
if (left <= 0)
break;
changed.Wait(mutex, (i32)left);
}
bool result = set;
set = false;
mutex.Unlock();
return result;
}
}
}