diff --git a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpInterceptorAdapter.cs b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpInterceptorAdapter.cs index c8ba229979..00dc33a59a 100644 --- a/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpInterceptorAdapter.cs +++ b/framework/src/Volo.Abp.Castle.Core/Volo/Abp/Castle/DynamicProxy/CastleAbpInterceptorAdapter.cs @@ -9,13 +9,6 @@ namespace Volo.Abp.Castle.DynamicProxy public class CastleAbpInterceptorAdapter : IInterceptor where TInterceptor : IAbpInterceptor { - private static readonly MethodInfo MethodExecuteWithoutReturnValueAsync = - typeof(CastleAbpInterceptorAdapter) - .GetMethod( - nameof(ExecuteWithoutReturnValueAsync), - BindingFlags.NonPublic | BindingFlags.Instance - ); - private static readonly MethodInfo MethodExecuteWithReturnValueAsync = typeof(CastleAbpInterceptorAdapter) .GetMethod( @@ -36,22 +29,20 @@ namespace Volo.Abp.Castle.DynamicProxy var method = invocation.MethodInvocationTarget ?? invocation.Method; - if (method.IsAsync()) - { - InterceptAsyncMethod(invocation, proceedInfo); - } - else + if (!method.IsAsync()) { proceedInfo.Invoke(); + return; } + + InterceptAsyncMethod(invocation, proceedInfo); } private void InterceptAsyncMethod(IInvocation invocation, IInvocationProceedInfo proceedInfo) { if (invocation.Method.ReturnType == typeof(Task)) { - invocation.ReturnValue = MethodExecuteWithoutReturnValueAsync - .Invoke(this, new object[] { invocation, proceedInfo }); + invocation.ReturnValue = ExecuteWithoutReturnValueAsync(invocation, proceedInfo); } else { @@ -63,8 +54,6 @@ namespace Volo.Abp.Castle.DynamicProxy private async Task ExecuteWithoutReturnValueAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo) { - await Task.Yield(); - await _abpInterceptor.InterceptAsync( new CastleAbpMethodInvocationAdapter(invocation, proceedInfo) );