Class AsyncUtils

Helper class to run async methods within a sync process. Source: https://www.ryadel.com/en/asyncutil-c-helper-class-async-method-sync-result-wait/

System.Object
  Westwind.Utilities.AsyncUtils
public static class AsyncUtils : object

Class Members

MemberDescription

DelayExecution

Executes an Action after a delay

public static void DelayExecution(int delayMs,     Action action,     Action errorHandler)

DelayExecution

public static void DelayExecution(int delayMs,     Action action,     T parm,     Action errorHandler)

FireAndForget

Ensures safe operation of a task without await even if an execution fails with an exception. This forces the exception to be cleared unlike a non-continued task.

public static void FireAndForget(Task t)

public static void FireAndForget(Task t,     Action del)

RunSync

Executes an async Task method which has a void return value synchronously USAGE: AsyncUtil.RunSync(() => AsyncMethod());

public static void RunSync(Func task)

public static void RunSync(Func task,     CancellationToken cancellationToken,     TaskCreationOptions taskCreation,     TaskContinuationOptions taskContinuation,     TaskScheduler taskScheduler)

RunSync

public static TResult RunSync(Func<Task`1> task)

public static TResult RunSync(Func<Task`1> func,     CancellationToken cancellationToken,     TaskCreationOptions taskCreation,     TaskContinuationOptions taskContinuation,     TaskScheduler taskScheduler)

Requirements

Namespace: Westwind.Utilities
Assembly: westwind.utilities.dll

© West Wind Technologies, 1996-2024 • Updated: 06/29/24
Comment or report problem with topic