Home Microsoft Azure .NET SDK Sync on Async
Reply: 0

Microsoft Azure .NET SDK Sync on Async

user850
1#
user850 Published in August 15, 2018, 9:02 am

I am using the Azure Blob Storage SDK Microsoft.WindowsAzure.Storage for my ASP.NET application. I have seen some synchronous method calling asynchronous method. They use an helper method named RunWithoutSynchronizationContext from Microsoft.WindowsAzure.Storage.Core.Util.

The code is basically doing something like

  SynchronizationContext current = SynchronizationContext.Current;
  try
  {
    SynchronizationContext.SetSynchronizationContext((SynchronizationContext) null);
    methodAsync().Wait();
  }
  finally
  {
    SynchronizationContext.SetSynchronizationContext(current);
  }

I was just wondering if this is a way to avoid deadlock in .NET Framework when blocking on asynchronous code? If not, then what is it the purpose of this method?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299748 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO