<PackageReference Include="NLog" Version="6.1.3" />

NLog.Common.AsyncHelpers

public static class AsyncHelpers
Helpers for asynchronous operations.
public static void ForEachItemInParallel<T>(IEnumerable<T> values, AsyncContinuation asyncContinuation, AsynchronousAction<T> action)

Iterates over all items in the given collection and runs the specified action in parallel (each action executes on a thread from thread pool).

public static void ForEachItemSequentially<T>(IEnumerable<T> items, AsyncContinuation asyncContinuation, AsynchronousAction<T> action)

Iterates over all items in the given collection and runs the specified action in sequence (each action executes only after the preceding one has completed without an error).

public static Exception GetCombinedException(IList<Exception> exceptions)

Gets the combined exception from all exceptions in the list.

public static AsyncContinuation PrecededBy(AsyncContinuation asyncContinuation, AsynchronousAction action)

Modifies the continuation by pre-pending given action to execute just before it.

public static AsyncContinuation PreventMultipleCalls(AsyncContinuation asyncContinuation)

Wraps the continuation with a guard which will only make sure that the continuation function is invoked only once.

public static void Repeat(int repeatCount, AsyncContinuation asyncContinuation, AsynchronousAction action)

Repeats the specified asynchronous action multiple times and invokes asynchronous continuation at the end.

public static void RunSynchronously(AsynchronousAction action)

Runs the specified asynchronous action synchronously (blocks until the continuation has been invoked).

public static AsyncContinuation WithTimeout(AsyncContinuation asyncContinuation, TimeSpan timeout)

Attaches a timeout to a continuation which will invoke the continuation when the specified timeout has elapsed.