Class AsyncHelper
Provides some helper methods to work with async methods.
Inheritance
System.Object
AsyncHelper
Namespace: Volo.Abp.Threading
Assembly: Volo.Abp.Core.dll
Syntax
public static class AsyncHelper : object
Methods
IsAsync(MethodInfo)
Checks if given method is an async method.
Declaration
public static bool IsAsync(this MethodInfo method)
Parameters
Type | Name | Description |
---|---|---|
MethodInfo | method | A method to check |
Returns
Type | Description |
---|---|
System.Boolean |
IsTaskOfT(Type)
Declaration
public static bool IsTaskOfT(this Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type |
Returns
Type | Description |
---|---|
System.Boolean |
IsTaskOrTaskOfT(Type)
Declaration
public static bool IsTaskOrTaskOfT(this Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type |
Returns
Type | Description |
---|---|
System.Boolean |
RunSync(Func<Task>)
Runs a async method synchronously.
Declaration
public static void RunSync(Func<Task> action)
Parameters
Type | Name | Description |
---|---|---|
Func<Task> | action | An async action |
RunSync<TResult>(Func<Task<TResult>>)
Runs a async method synchronously.
Declaration
public static TResult RunSync<TResult>(Func<Task<TResult>> func)
Parameters
Type | Name | Description |
---|---|---|
Func<Task<TResult>> | func | A function that returns a result |
Returns
Type | Description |
---|---|
TResult | Result of the async operation |
Type Parameters
Name | Description |
---|---|
TResult | Result type |
UnwrapTask(Type)
Returns void if given type is Task. Return T, if given type is Task{T}. Returns given type otherwise.
Declaration
public static Type UnwrapTask(Type type)
Parameters
Type | Name | Description |
---|---|---|
Type | type |
Returns
Type | Description |
---|---|
Type |