In this example an asynchronous request is made and when it has completed, another asynchronous request is made from its callback. How could I be notified from the first thread (main) when the second callback is completed? Normally I would monitor the IAsyncResult, but the creation of the second request is not done in the scope of the first thread, so I don’t have access to it.
In this example an asynchronous request is made and when it has completed, another
Share
The easiest way to get around this is probably not to do it – the second callback could be made syncronous (using
GetResponseinstead ofBeginGetResponse), then you can just monitor the IAsyncResult.Alternatively you could also use the same method they use to keep the main thread from ending: create another
then use in the first callback
and call
in the second callback