task.Result never makes call or returns value
Closed this issue · 5 comments
I have integrated this example into my application and have followed the code line by line and everything seems to be equivalent however, in the example app you put the email into the ViewBag using the following code
ViewBag.Email = await graphService.GetMyEmailAddress(graphClient);
in my application I am using the following:
String email = graphService.GetMyEmailAddress(graphClient).Result;
but the callout to the service endpoint never happens and this code never resumes - it is like it just ends abruptly (thread abort)
I am fairly new to the async / await pattern so I am assuming it has something to do with this - but based on my reading this should work
What am I doing wrong?
Thanks in advance.
It's a best practice to use await "all the way down." Have you read this piece on async best practices?
I have narrowed it down to the fact that it is executed in a old style synchronous .ashx handler and because it is executed on a different thread it looks like the call is never made when in fact it is actually making the call correctly (verified thru Fiddler as well as stepping through the code line by line once I got the SDK)
Mixing the asynch/await pattern into my application, which I just converted from aspx pages is not a trivial task (since asynch/await has been likened to a virus that will spread throughout your code and my code-base is large)
I am looking for two things - 1) can anyone support my suspicion that it is mixing the two patterns that is cause the issue (I think jamescro has already done this), and 2) what are my options, is a non asynch/await version of the library going to be made available.
Thanks in advance.
Thanks for the clarifications. Could you post this question to Stack Overflow? It looks like something that others will run into, so any solutions would be recorded in a place where more people could see it. The issue also doesn't related directly to the sample.
Will do
However the last question is definitely relevant to this forum - is an non-async version of this library going to be created (and ideally maintained going forward)
Thanks. You can direct your question about the library (and any other questions about the library) in the microsoft-dotnet-sdk repo. That's where the library source lives.