DataServiceContextWrapper can deadlock calling accessTokenGetter
Closed this issue · 0 comments
danyoel commented
BuildingRequest += (sender, args) =>
args.Headers.Add("Authorization", "Bearer " + _accessTokenGetter().Result);
The DataServiceContextWrapper
constructor registers an event handler which calls the async accessTokenGetter
method, but gets the result through .Result
rather than using await
. For a background of why can deadlock, see Stephen Cleary's post. A possible solution is to use ConfigureAwait(false).Result
if absolutely necessary.
In my own ASP.NET MVC app, I observe the deadlock happening 100% of the time.