I have to call some async methods in the Application_PostAcquireRequestState method of my Global.asax (these methods comes from a library and there's no equivalent sync method for these operations). I want to be sure this async code complete before continuing with my page process because some security parameters are set with the result of that async call.
What will be the proper way to make this work without creating deadlocks ?
Thanks
Just call the Result
property of the Task
that the *Async()
methods return, for example.
var result = BarAsync().Result;
If the methods return Task
rather than Task<T>
, use Wait()
:
BarAsync().Wait();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With