Class ManualResetEventEx
A disposable wrapper around ManualResetEventSlim for cross-thread signaling. One or more threads can Wait() on this event; a single call to Set() releases all of them simultaneously. The event can be reused by calling Reset() to return it to the non-signaled state.
Implements
Inherited Members
Namespace: Scylla.Core.Util
Assembly: ScyllaCore.dll
Syntax
public sealed class ManualResetEventEx : IDisposable
Remarks
Prefers ManualResetEventSlim over the heavier ManualResetEvent because it uses a spin-wait phase before falling back to a kernel wait handle. This makes it significantly faster for scenarios where the expected wait time is very short (sub-millisecond), which is common in game-engine worker threads.
Always dispose this object when it is no longer needed, either via a using
statement or an explicit call to Dispose(). Calling any method after
disposal throws ObjectDisposedException.
Constructors
ManualResetEventEx()
Initializes a new ManualResetEventEx in the non-signaled state. Threads that call Wait() will block until Set() is called.
Declaration
public ManualResetEventEx()
ManualResetEventEx(bool)
Initializes a new ManualResetEventEx with the specified initial state.
Declaration
public ManualResetEventEx(bool initialState)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | initialState |
|
Properties
IsSet
Gets a value indicating whether the event is currently in the signaled state.
Returns false if the object has been disposed.
Declaration
public bool IsSet { get; }
Property Value
| Type | Description |
|---|---|
| bool |
|
Methods
Dispose()
Releases all resources held by this ManualResetEventEx, including the underlying ManualResetEventSlim and its kernel wait handle (if one was allocated). After disposal, all method calls on this instance throw ObjectDisposedException. Calling Dispose() more than once is safe and has no additional effect.
Declaration
public void Dispose()
Reset()
Returns the event to the non-signaled state. Threads that subsequently call Wait() will block again until Set() is called once more. Has no effect if the event is already non-signaled.
Declaration
public void Reset()
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | Thrown if Dispose() has already been called on this instance. |
See Also
Set()
Transitions the event to the signaled state, releasing all threads currently blocked in Wait(). The event remains signaled until Reset() is called; subsequent Wait() calls return immediately while the event is signaled.
Declaration
public void Set()
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | Thrown if Dispose() has already been called on this instance. |
See Also
Wait()
Blocks the calling thread indefinitely until the event enters the signaled state. Returns immediately if the event is already signaled.
Declaration
public void Wait()
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | Thrown if Dispose() has already been called on this instance. |
See Also
Wait(int)
Blocks the calling thread until the event enters the signaled state or the timeout expires. Returns immediately if the event is already signaled.
Declaration
public bool Wait(int millisecondsTimeout)
Parameters
| Type | Name | Description |
|---|---|---|
| int | millisecondsTimeout | The maximum number of milliseconds to wait. Pass Infinite ( |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | Thrown if Dispose() has already been called on this instance. |
See Also
Wait(TimeSpan)
Blocks the calling thread until the event enters the signaled state or the specified timeout duration elapses. Returns immediately if the event is already signaled.
Declaration
public bool Wait(TimeSpan timeout)
Parameters
| Type | Name | Description |
|---|---|---|
| TimeSpan | timeout | The maximum duration to wait. Use Zero to test the current
state without blocking. Negative values other than |
Returns
| Type | Description |
|---|---|
| bool |
|
Exceptions
| Type | Condition |
|---|---|
| ObjectDisposedException | Thrown if Dispose() has already been called on this instance. |