Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. public async Task<ActionResult> Index()
  2. {
  3. await Task.Run(() => do some stuff);
  4. // Will schedule continuation on the synchronization context causing deadlock in ASP for .NET Framework,
  5. // but is legit in project type like console app or tests because synchronization context doesn't exist there.
  6.  
  7. await Task.Run(() => do some stuff).ConfigureAwait(false); \
  8. // This is ok in all of the above cases. It will schedule continuation on a thread pool thread.
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement