ManualResetEvent class
A manual-reset event for tasks.
- Use
import ThinkMeta.ConcurrentTasks.Synchronization.ManualResetEvent;- Namespace
ThinkMeta::ConcurrentTasks::Synchronization- Inherits
Waitable,ISuspendCallback
Syntax
using ManualResetEvent = _ManualResetEvent<SuspensionKind::Multiple>;
using ManualResetEvent_s = _ManualResetEvent<SuspensionKind::Single>;Template parameters
_SuspensionKindSuspensionKindSuspensionKind::Multiple: any number of waiting tasks;SuspensionKind::Single: at most one waiting task at a time, cheaper, with timeouts.
Remarks
While set, every Wait passes; Set resumes all waiting tasks. Comes as ManualResetEvent (any number of waiters) and ManualResetEvent_s (one waiter). Wait suspends the calling task and needs a task or an OS thread converted with ConvertThreadToTask. Set, Reset and TryWait never suspend and may be called from any thread (the core's I/O thread calls Set). No member reports errors. ManualResetEvent: any number of waiters, no timeouts. Destroy the event only when no task can wait on it or set it any more and the last Set has returned; the return of a Wait alone does not mean that, since Set may still be resuming other waiters (ManualResetEvent_s allows destroying it right after the wait).
See also
AutoResetEvent, SuspensionKind
Names
| Name | Description |
|---|---|
ManualResetEvent |
Manual-reset event for any number of waiting tasks (no timeouts). |
ManualResetEvent_s |
Manual-reset event for at most one waiting task.
Cheaper than |
Constructors
ManualResetEvent
Creates the event.
Syntax
explicit ManualResetEvent(bool isSet = false) noexcept;Parameters
isSetbooltrueto create it set.Default:false
~ManualResetEvent
Destroys the event.
Syntax
~ManualResetEvent() noexcept;Remarks
No task may be waiting on it (asserted in Debug).
Methods
Set
Reset
TryWait
Tells whether the event is set, without changing it.
Syntax
[[nodiscard]] bool TryWait() noexcept;Return value
Type: bool
true if the event is set; otherwise false.
Remarks
Never suspends; any thread.
See also
Wait
Waits until the event is set.
Syntax
void Wait() noexcept;Remarks
Returns at once if the event is set, otherwise suspends the calling task until Set. Task or converted thread only; at most one waiter at a time.
See also
Waits until the event is set, with a time limit.
Syntax
[[nodiscard]] bool Wait(Duration timeout) noexcept;Parameters
timeoutDuration- The longest time to wait. Needs
EnableTimers; without it the wait has no limit.
Return value
Type: bool
true if the event is set; false if it timed out: the task no longer waits on the event; the event may be set later.
Remarks
Task or converted thread only.
See also
Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).