Skip to content

Class EnumerableExtensions

Namespace: Void.Proxy.Api.Extensions
Assembly: Void.Proxy.Api.dll

Provides enumeration helpers that hold an asynchronous-compatible lock for the duration of enumeration.

public static class EnumerableExtensions

Inheritance

objectEnumerableExtensions

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Methods

Synchronized<T>(IEnumerable<T>, AsyncLock, CancellationToken)

Enumerates a sequence while synchronously holding an .

public static IEnumerable<T> Synchronized<T>(this IEnumerable<T> source, AsyncLock @lock, CancellationToken cancellationToken)

Parameters

source IEnumerable<T>

The sequence to enumerate.

lock AsyncLock

The lock held from the first move until enumeration ends or is disposed.

cancellationToken CancellationToken

A token used to cancel lock acquisition and stop further enumeration.

Returns

IEnumerable<T>

A lazy sequence whose enumerator owns the lock while active.

Type Parameters

T

The sequence element type.

SynchronizedAsync<T>(IEnumerable<T>, AsyncLock, CancellationToken)

Asynchronously enumerates a sequence while holding an .

public static IAsyncEnumerable<T> SynchronizedAsync<T>(this IEnumerable<T> source, AsyncLock @lock, CancellationToken cancellationToken)

Parameters

source IEnumerable<T>

The sequence to enumerate.

lock AsyncLock

The lock held from the first move until asynchronous enumeration ends or is disposed.

cancellationToken CancellationToken

A token used to cancel lock acquisition and stop further enumeration.

Returns

IAsyncEnumerable<T>

A lazy asynchronous sequence whose enumerator owns the lock while active.

Type Parameters

T

The sequence element type.