Class AsyncHelper
- Namespace
- SunamoAsync
- Assembly
- SunamoAsync.dll
Helper class for running async methods synchronously.
public class AsyncHelper
- Inheritance
-
AsyncHelper
- Inherited Members
- Extension Methods
Fields
Instance
Singleton instance of AsyncHelper.
public static AsyncHelper Instance
Field Value
Methods
GetResult(Task)
Gets the result of a task synchronously.
public void GetResult(Task task)
Parameters
taskTaskThe task to get result from.
GetResult<T>(Task<T>)
Gets the result of a typed task synchronously.
public T GetResult<T>(Task<T> task)
Parameters
taskTask<T>The task to get result from.
Returns
- T
Type Parameters
TThe type of the task result.
InvokeFuncTaskOrAction(object)
Invokes either an Action or a Func<Task> asynchronously.
public static Task InvokeFuncTaskOrAction(object actionOrFunc)
Parameters
actionOrFuncobjectThe action or function to invoke.
Returns
RunAsync(Task)
Runs a task asynchronously.
public Task RunAsync(Task task)
Parameters
taskTaskThe task to run.
Returns
RunSyncWithoutReturnValue(Func<Task>)
Executes an async method synchronously without return value.
public void RunSyncWithoutReturnValue(Func<Task> task)
Parameters
RunSyncWithoutReturnValue<T1>(Func<T1, Task>, T1)
Executes an async method with one parameter synchronously without return value.
public void RunSyncWithoutReturnValue<T1>(Func<T1, Task> task, T1 argument1)
Parameters
Type Parameters
T1First parameter type.
RunSyncWithoutReturnValue<T1, T2>(Func<T1, T2, Task>, T1, T2)
Executes an async method with two parameters synchronously without return value.
public void RunSyncWithoutReturnValue<T1, T2>(Func<T1, T2, Task> task, T1 argument1, T2 argument2)
Parameters
taskFunc<T1, T2, Task>Async method to execute.
argument1T1First argument.
argument2T2Second argument.
Type Parameters
T1First parameter type.
T2Second parameter type.
RunSyncWithoutReturnValue<T1, T2, T3>(Func<T1, T2, T3, Task>, T1, T2, T3)
Executes an async method with three parameters synchronously without return value.
public void RunSyncWithoutReturnValue<T1, T2, T3>(Func<T1, T2, T3, Task> task, T1 argument1, T2 argument2, T3 argument3)
Parameters
taskFunc<T1, T2, T3, Task>Async method to execute.
argument1T1First argument.
argument2T2Second argument.
argument3T3Third argument.
Type Parameters
T1First parameter type.
T2Second parameter type.
T3Third parameter type.
RunSync<T, T1>(Func<T1, T>, T1)
Executes a function with one parameter synchronously and returns its result.
public T RunSync<T, T1>(Func<T1, T> task, T1 argument1)
Parameters
taskFunc<T1, T>Function to execute.
argument1T1First argument.
Returns
- T
Type Parameters
TReturn type.
T1First parameter type.
RunSync<T, T1, T2>(Func<T1, T2, T>, T1, T2)
Executes a function with two parameters synchronously and returns its result.
public T? RunSync<T, T1, T2>(Func<T1, T2, T> task, T1 argument1, T2 argument2)
Parameters
taskFunc<T1, T2, T>Function to execute.
argument1T1First argument.
argument2T2Second argument.
Returns
- T
Type Parameters
TReturn type.
T1First parameter type.
T2Second parameter type.
RunSync<T, T1, T2, T3>(Func<T1, T2, T3, T>, T1, T2, T3)
Executes a function with three parameters synchronously and returns its result.
public T RunSync<T, T1, T2, T3>(Func<T1, T2, T3, T> task, T1 argument1, T2 argument2, T3 argument3)
Parameters
taskFunc<T1, T2, T3, T>Function to execute.
argument1T1First argument.
argument2T2Second argument.
argument3T3Third argument.
Returns
- T
Type Parameters
TReturn type.
T1First parameter type.
T2Second parameter type.
T3Third parameter type.