Class AsyncHelper
Reference https://cpratt.co/async-tips-tricks/
Inherited Members
Namespace: Innovt.Core.Utilities
Assembly: Innovt.Core.dll
Syntax
public static class AsyncHelper
Methods
| Edit this page View SourceRunSync(Func<Task>, CancellationToken)
Runs an asynchronous action synchronously.
Declaration
public static void RunSync(Func<Task> func, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | func | The asynchronous action to run synchronously. |
CancellationToken | cancellationToken | An optional cancellation token for the operation. |
RunSync<TResult>(Func<Task<TResult>>, CancellationToken)
Runs an asynchronous function synchronously and returns its result.
Declaration
public static TResult RunSync<TResult>(Func<Task<TResult>> func, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Func<Task<TResult>> | func | The asynchronous function to run synchronously. |
CancellationToken | cancellationToken | An optional cancellation token for the operation. |
Returns
Type | Description |
---|---|
TResult | The result of the asynchronous function. |
Type Parameters
Name | Description |
---|---|
TResult | The type of the result returned by the asynchronous function. |