--
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-u...@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.
-- Sent from my Android phone with K-@ Mail. Please excuse my brevity.
// Castle.Proxies.IMyServiceProxy
public virtual Task<bool> GetResult()
{
IMyService arg_19_0 = null;
IInterceptor[] arg_19_2 = this.__interceptors;
MethodInfo arg_19_3 = IMyServiceProxy.token_GetResult;
object[] array = new object[0];
IMyService_GetResult myService_GetResult = new IMyService_GetResult(arg_19_0, this, arg_19_2, arg_19_3, array);
myService_GetResult.Proceed();
return (Task<bool>)myService_GetResult.get_ReturnValue();
}
--
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+unsub...@googlegroups.com.