Task support isnt quite required. Just get the result of the method
call, and if it's a task, act accordingly (check for completion, add
continuation, etc)

On Mon, Mar 14, 2016 at 12:44 PM, Rich Private <richwalise...@gmail.com> wrote:
> Mauricio,
>
> Are there any updates as to whether or not DynamicProxy will support "async
> Task Intercept" ?
>
> On Saturday, July 20, 2013 at 6:09:21 PM UTC-5, Mauricio Scheffer wrote:
>>
>> Ah, I see what you mean now. Have you considered using a higher-order
>> function (or a decorator) instead of a proxy?
>>
>>
>>
>> --
>> Mauricio
>>
>>
>> On Fri, Jul 19, 2013 at 6:22 AM, Kristijan Horvat <kho...@icodeteam.net>
>> wrote:
>>>
>>> Ok, np I have a BeforeInvoke method that I need to await so my code looks
>>> more like this:
>>>
>>>  public class AsyncInterceptor : IInterceptor {
>>>         public async void Intercept(IInvocation invocation) {
>>>             await BeforeInvoke();
>>>             invocation.Proceed();
>>>             var result = await (Task<string>)invocation.ReturnValue;
>>>             invocation.ReturnValue = Task.Factory.StartNew(async () => {
>>>                 var h = new HttpClient();
>>>                 var response = await h.GetAsync("http://www.bing.com";);
>>>                 var content = await response.Content.ReadAsStringAsync();
>>>                 return content + result;
>>>             });
>>>         }
>>>     }
>>>
>>> At that "await BeforeInvoke();" point control is passed back to caller
>>> and that is the proxy method that I have provided you with and in your case
>>> it would be translated to something similar to this:
>>>
>>>     IAsyncClass_GetSomething asyncClass_GetSomething = new
>>> IAsyncClass_GetSomething(arg_19_0, this, arg_19_2, arg_19_3, array);
>>>     asyncClass_GetSomething.Proceed();
>>>
>>> Well Proceed is not awaited and then control is passed one level up, at
>>> that point you aren't waiting for result anymore. So problem is awaiting
>>> anything before "invocation.Proceed();" because proxy isn't generating async
>>> code.
>>> (http://stackoverflow.com/questions/17663808/making-ninject-interceptors-intercept-method-an-async-method
>>> - take a look at Stephen Cleary comment) I have inspected LinFu DynamicProxy
>>> and it seems that he is generating more acceptable code for this kind of
>>> scenario. I'm testing the code right now I can post the results as soon as
>>> I'm done.
>>>
>>> Thanks
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Castle Project Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to castle-project-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to castle-pro...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/castle-project-users.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to castle-project-users+unsubscr...@googlegroups.com.
> To post to this group, send email to castle-project-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/castle-project-users.
> For more options, visit https://groups.google.com/d/optout.



-- 
Cheers,
hammett
http://www.d-collab.com/
http://www.hammettblog.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to castle-project-users+unsubscr...@googlegroups.com.
To post to this group, send email to castle-project-users@googlegroups.com.
Visit this group at https://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to