ninject / Ninject.Extensions.Interception

Interception extension for Ninject
Other
58 stars 27 forks source link

Async support for IInterceptor Intercept #17

Closed khorvat closed 11 years ago

khorvat commented 11 years ago

Hi,

is there any plans to introduce InterceptAsync or something similar in Interception extension in order to support awaiting asynchronous calls ?

Thanks

StephenCleary commented 11 years ago

This SO answer shows how you can add async operations after a call to an async method, but there isn't a way to do async operations before the call.

To support this, we'd need something like InterceptAsync. WebAPI has a very similar design in their delegating handlers.

khorvat commented 11 years ago

I have had to hack the extension in order for this to work, you can find more details here - http://stackoverflow.com/a/17789809, and Forked repository here - https://github.com/khorvat/ninject.extensions.interception

khorvat commented 11 years ago

I have taken a look at your implementation and wondering if async/await calls are possible in BeforeInvoke ?

Thanks

remogloor commented 11 years ago

What do you want to await in BeforeInvoke? The task that has not even created and started? You would wait infinit in this case.

khorvat commented 11 years ago

Let's say you have some preprocessing for few intercepted services and that you have an async operation in BeforeInvoke (e.g. reading from disk, distributed cache or something) you are not possible to await that operation.

Thoughts ?