Table of Contents

Class AsyncAutoResetEventSlim

Namespace
CounterpointCollective.Threading
Assembly
CounterpointCollective.Threading.dll

Represents a lightweight, asynchronous auto-reset event.

public class AsyncAutoResetEventSlim
Inheritance
AsyncAutoResetEventSlim
Inherited Members

Remarks

This class provides a thread-safe, asynchronous alternative to AutoResetEvent. It allows one waiting task to proceed when the event is set, and automatically resets after a single waiter consumes the event.

Features include:

Usage notes:

Constructors

AsyncAutoResetEventSlim(bool)

Represents a lightweight, asynchronous auto-reset event.

public AsyncAutoResetEventSlim(bool startSet)

Parameters

startSet bool

Remarks

This class provides a thread-safe, asynchronous alternative to AutoResetEvent. It allows one waiting task to proceed when the event is set, and automatically resets after a single waiter consumes the event.

Features include:

Usage notes:

Properties

IsSet

Gets a value indicating whether the event is currently set.

  • true if the event is set and has not yet been consumed by a waiter.
  • false if the event is not set or if it has been terminated via Terminate().
This property is thread-safe but does not reserve the event; a concurrent WaitOneAsync(CancellationToken) may consume the set immediately after reading.
public bool IsSet { get; }

Property Value

bool

Terminated

public bool Terminated { get; }

Property Value

bool

Methods

Reset()

public void Reset()

Set()

Sets the event, allowing a single waiter to proceed.Typically used to signal that a condition or resource is available for one waiting task.

public void Set()

Remarks

  • If the event is already set, this method does nothing.
  • If the event has been terminated via Terminate(), calling this method has no effect.

Terminate()

public void Terminate()

WaitOne()

public void WaitOne()

WaitOne(TimeSpan)

public bool WaitOne(TimeSpan t)

Parameters

t TimeSpan

Returns

bool

WaitOneAsync(CancellationToken)

public Task WaitOneAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task

WaitOneAsync(TimeSpan)

public Task<bool> WaitOneAsync(TimeSpan t)

Parameters

t TimeSpan

Returns

Task<bool>