Skip to content

await inside InterceptAsynchronous<TResult>(IInvocation invocation) #191

Answered by JSkimming
azresource asked this question in Q&A
Discussion options

You must be logged in to vote

@azresource I think I've got it. You've highlighted a failing of the documentation. When you need to make an async call before calling Proceed(), then you must call IInvocationProceedInfo proceedInfo = invocation.CaptureProceedInfo(); prior to the async call. Then proceedInfo.Invoke(); afterward, instead of calling invocation.Proceed();

invocation.CaptureProceedInfo(); has an overhead, so if you don't need to make an async call, you can just call invocation.Proceed();. You can simplify this by always calling proceedInfo = invocation.CaptureProceedInfo(); then proceedInfo.Invoke(); Though it will be slower when you don't make an async call before invocation.

Here's your updated code. Pleas…

Replies: 6 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@azresource
Comment options

@JSkimming
Comment options

Comment options

You must be logged in to vote
1 reply
@JSkimming
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by azresource
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants