@ -9,9 +9,9 @@ namespace Volo.Abp.Threading;
//TODO: Cache GetMethod reflection!
public static class InternalAsyncHelper
{
public static async Task AwaitTaskWithFinally ( Task actualReturnValue , Action < Exception > finalAction )
public static async Task AwaitTaskWithFinally ( Task actualReturnValue , Action < Exception ? > finalAction )
{
Exception exception = null ;
Exception ? exception = null ;
try
{
@ -28,9 +28,9 @@ public static class InternalAsyncHelper
}
}
public static async Task AwaitTaskWithPostActionAndFinally ( Task actualReturnValue , Func < Task > postAction , Action < Exception > finalAction )
public static async Task AwaitTaskWithPostActionAndFinally ( Task actualReturnValue , Func < Task > postAction , Action < Exception ? > finalAction )
{
Exception exception = null ;
Exception ? exception = null ;
try
{
@ -48,9 +48,9 @@ public static class InternalAsyncHelper
}
}
public static async Task AwaitTaskWithPreActionAndPostActionAndFinally ( Func < Task > actualReturnValue , Func < Task > preAction = null , Func < Task > postAction = null , Action < Exception > finalAction = null )
public static async Task AwaitTaskWithPreActionAndPostActionAndFinally ( Func < Task > actualReturnValue , Func < Task > ? preAction = null , Func < Task > ? postAction = null , Action < Exception ? >? finalAction = null )
{
Exception exception = null ;
Exception ? exception = null ;
try
{
@ -80,9 +80,9 @@ public static class InternalAsyncHelper
}
}
public static async Task < T > AwaitTaskWithFinallyAndGetResult < T > ( Task < T > actualReturnValue , Action < Exception > finalAction )
public static async Task < T > AwaitTaskWithFinallyAndGetResult < T > ( Task < T > actualReturnValue , Action < Exception ? > finalAction )
{
Exception exception = null ;
Exception ? exception = null ;
try
{
@ -103,14 +103,14 @@ public static class InternalAsyncHelper
{
return typeof ( InternalAsyncHelper )
. GetTypeInfo ( )
. GetMethod ( "AwaitTaskWithFinallyAndGetResult" , BindingFlags . Public | BindingFlags . Static )
. GetMethod ( "AwaitTaskWithFinallyAndGetResult" , BindingFlags . Public | BindingFlags . Static ) !
. MakeGenericMethod ( taskReturnType )
. Invoke ( null , new object [ ] { actualReturnValue , finalAction } ) ;
. Invoke ( null , new object [ ] { actualReturnValue , finalAction } ) ! ;
}
public static async Task < T > AwaitTaskWithPostActionAndFinallyAndGetResult < T > ( Task < T > actualReturnValue , Func < Task > postAction , Action < Exception > finalAction )
public static async Task < T > AwaitTaskWithPostActionAndFinallyAndGetResult < T > ( Task < T > actualReturnValue , Func < Task > postAction , Action < Exception ? > finalAction )
{
Exception exception = null ;
Exception ? exception = null ;
try
{
@ -133,14 +133,14 @@ public static class InternalAsyncHelper
{
return typeof ( InternalAsyncHelper )
. GetTypeInfo ( )
. GetMethod ( "AwaitTaskWithPostActionAndFinallyAndGetResult" , BindingFlags . Public | BindingFlags . Static )
. GetMethod ( "AwaitTaskWithPostActionAndFinallyAndGetResult" , BindingFlags . Public | BindingFlags . Static ) !
. MakeGenericMethod ( taskReturnType )
. Invoke ( null , new object [ ] { actualReturnValue , action , finalAction } ) ;
. Invoke ( null , new object [ ] { actualReturnValue , action , finalAction } ) ! ;
}
public static async Task < T > AwaitTaskWithPreActionAndPostActionAndFinallyAndGetResult < T > ( Func < Task < T > > actualReturnValue , Func < Task > preAction = null , Func < Task > postAction = null , Action < Exception > finalAction = null )
public static async Task < T > AwaitTaskWithPreActionAndPostActionAndFinallyAndGetResult < T > ( Func < Task < T > > actualReturnValue , Func < Task > ? preAction = null , Func < Task > ? postAction = null , Action < Exception ? >? finalAction = null )
{
Exception exception = null ;
Exception ? exception = null ;
try
{
@ -169,19 +169,19 @@ public static class InternalAsyncHelper
}
}
public static object CallAwaitTaskWithPreActionAndPostActionAndFinallyAndGetResult ( Type taskReturnType , Func < object > actualReturnValue , Func < Task > preAction = null , Func < Task > postAction = null , Action < Exception > finalAction = null )
public static object CallAwaitTaskWithPreActionAndPostActionAndFinallyAndGetResult ( Type taskReturnType , Func < object > actualReturnValue , Func < Task > ? preAction = null , Func < Task > ? postAction = null , Action < Exception > ? finalAction = null )
{
var returnFunc = typeof ( InternalAsyncHelper )
. GetTypeInfo ( )
. GetMethod ( "ConvertFuncOfObjectToFuncOfTask" , BindingFlags . NonPublic | BindingFlags . Static )
. GetMethod ( "ConvertFuncOfObjectToFuncOfTask" , BindingFlags . NonPublic | BindingFlags . Static ) !
. MakeGenericMethod ( taskReturnType )
. Invoke ( null , new object [ ] { actualReturnValue } ) ;
return typeof ( InternalAsyncHelper )
. GetTypeInfo ( )
. GetMethod ( "AwaitTaskWithPreActionAndPostActionAndFinallyAndGetResult" , BindingFlags . Public | BindingFlags . Static )
. GetMethod ( "AwaitTaskWithPreActionAndPostActionAndFinallyAndGetResult" , BindingFlags . Public | BindingFlags . Static ) !
. MakeGenericMethod ( taskReturnType )
. Invoke ( null , new object [ ] { returnFunc , preAction , postAction , finalAction } ) ;
. Invoke ( null , new object ? [ ] { returnFunc , preAction , postAction , finalAction } ) ! ;
}
[UsedImplicitly]