Closed sallgeud closed 6 years ago
There are several issues on this. There is a method available GetBytesAsync that will allow you to use ConfigureAwait to avoid deadlock. It effectively just exposes the same task so it gives you the option to control how you go about handling the synchronization contexts as the consumer of the library.
so while you can definetely use getbytesasync and configureawait to avoid deadlocks... the default synchronus method should not cause deadlocks... we implemented this as a simple function on webapi and it deadlocks 100% of the time with the sync method. Yes we switched to async, but should we have had to ?
You should consider wrapping this call in an AsyncBridge or investigate the use of ConfigureAwait, etc:
https://blogs.msdn.microsoft.com/pfxteam/2011/01/13/await-and-ui-and-deadlocks-oh-my/