Class AsyncHelper
Provides some helper methods to work with async methods.
public static class AsyncHelper
- Inheritance
-
AsyncHelper
- Inherited Members
Methods
IsAsync(MethodInfo)
Checks if given method is an async method.
public static bool IsAsync(this MethodInfo method)
Parameters
method
MethodInfoA method to check
Returns
IsTaskOfT(Type)
public static bool IsTaskOfT(this Type type)
Parameters
type
Type
Returns
IsTaskOrTaskOfT(Type)
public static bool IsTaskOrTaskOfT(this Type type)
Parameters
type
Type
Returns
RunSync(Func<Task>)
Runs a async method synchronously.
public static void RunSync(Func<Task> action)
Parameters
RunSync<TResult>(Func<Task<TResult>>)
Runs a async method synchronously.
public static TResult RunSync<TResult>(Func<Task<TResult>> func)
Parameters
Returns
- TResult
Result of the async operation
Type Parameters
TResult
Result type
UnwrapTask(Type)
Returns void if given type is Task. Return T, if given type is Task{T}. Returns given type otherwise.
public static Type UnwrapTask(Type type)
Parameters
type
Type