PostSharpAPI ReferencePost­Sharp.​AspectsMethod­Interception­AspectOn­Invoke­Async
Open sandboxFocus

MethodInterceptionAspect.OnInvokeAsync Method

OnInvokeAsync(MethodInterceptionArgs)

Method invoked instead of the method to which the aspect has been applied.

Declaration
[RequiresMethodInterceptionAdviceAnalysis]
[RequiresDebuggerEnhancement]
[HasInheritedAttribute]
[MethodInterceptionAdviceOptimization]
public virtual Task OnInvokeAsync(MethodInterceptionArgs args)
Parameters
Type Name Description
MethodInterceptionArgs args

Advice arguments.

Returns
Type Description
Task
Implements
IAsyncMethodInterceptionAspect.OnInvokeAsync(MethodInterceptionArgs)
Remarks

The implementation of OnInvokeAsync(MethodInterceptionArgs) may invoke ProceedAsync(), may schedule it for invocation from another thread, or may completely skip its invocation. Alternatively, it may use Binding. Before returning to the caller, the OnInvokeAsync(MethodInterceptionArgs) method must set the return value (property ReturnValue), otherwise the target method may fail with a NullReferenceException. It is normally set by calling ProceedAsync().

If semantic advising applies to a method and the method is an async method or returns a Task, then OnInvokeAsync(MethodInterceptionArgs) is called for that method instead of OnInvoke(MethodInterceptionArgs).

See Also