Similar but different to this question How do you implement an async action delegate method?
Hi, I have a method that takes two arguments and returns a result, In calculating the result it calls an awaitable function The arguments to the method are only accessible on another thread, so I'm using dispatcher.CheckAccess, dispatcher.Invoke or dispatcher.InvokeAsync. The best result I got so far is something that builds and runs, but the function never got hit even though dispatcher invoke was called.
I found the example in the referenced thread confusing due to the naming T result, whereas I thought T was an in parameter.
my function looks like this:
private async Task<TResult>> fn(object arg1, object arg2){return await x(arg1,arg2);}
dispatcher code looks something like this:
if (dispatcher.CheckAccess())
result= await fn(a,b);
else
result=dispatcher.InvokeAsync<TResult>(fn(a,b)); // this is incorrect syntax
Hopefully Stephen Cleary can rescue me :-) I couldn't find an example like this in Concurrency in C# Cookbook. Probably I'm looking at this wrong way?
Thanks Martin