last day (28 days later) » 

9:25 AM
0
A: Wait for an async method to return

DirkA quick solution would be to use a ManualResetEvent or ManualResetEventSlim, wait for it in the constructor and set it in the callback method: private readonly ManualResetEventSlim myEvent; public User(IFBGraphUser user) { myEvent = new ManualResetEventSlim(); id = user.GetId(); nam...

 
This just locks up the code forever..
 
@Deekor And why?
 
I just edited my question a bit.. Not sure if StartWithGraphPath is really async or not now based off trying this answer.
 
@Deekor I just don't see why this would lock up the code forver, unless the call to Set is never executed.
 
any idea as to why my output is the way it is then?
 
9:25 AM
@Deekor The call to StartWithGraphPath appears to be asynchronous. Why don't you simply use a debugger and set a breakpoint in the callback and constructor at the Wait and Set calls to see what happens.
 
it hits the wait. I click resume and it never hits the set.
 
I just tested it in LinqPad with some sample code and it works. If the call to Set is never reached then the problem is that you exit your callback before it, maybe because of an exception. Just step through your callback method to see what happens.
 
Ok one second
steps through fine no exception
Whats odd is there is also a method called StartWithGraphPathAsync
SO wouldn't this one Im using be synchronous by deduction?
It has a synchronous feel while in debugger but not when simply running the app
 
It's strange for sure. Unfortunately I don't know this API at all, the method I proposed can be used in general, but it has one deadlock scenario (check my edited post). If you can I would strongly suggest removing that call from the constructor. Is that call really required to be in the constructor?
 
I guess not but the email field does need to be populated as I am sending the info to a web service immediately
Thanks for your help. 4am here I need to get some sleep, hopefully I dream of the answer ;)
 

  last day (28 days later) »