Save 37% off PRO during our Black Friday Sale! »

Server Side Async, DEU Bilgisayar Topluluğu Izmir 2. Teknoloji Zirvesi (EN)

Server Side Async, DEU Bilgisayar Topluluğu Izmir 2. Teknoloji Zirvesi (EN)

* Slide template belongs to MIX 11 conference.
* A few parts of the content have been taken from other presentations (links to those presentations are available at the bottom-right corner for each slide).

3a53a5136f530c121a196914aecf3936?s=128

Tugberk Ugurlu

January 06, 2013
Tweet

Transcript

  1. http://tugberkugurlu.com tugberkugurlu@gmail.com @tourismgeek

  2. None
  3. None
  4. None
  5. None
  6. None
  7. ?

  8. Task1 Task 2 Task 3 1 2 3 4 5

    6 7 Call Started Waiting for the Operation to Complete (Blocked!) Other Tasks
  9. 1 2 8 9 5 6 7 Call Started Processing

    Other Tasks 3 4 Confimation for the Callback Task1 Task 2 Task 3
  10. Thread pool Requests Busy Busy Busy Busy

  11. Requests Thread pool

  12. None
  13. None
  14. None
  15. None
  16. None
  17. None
  18. None
  19. return Task.Factory.StartNew(() => { return forbiddenResponse; });

  20. return Task.FromResult(forbiddenResponse);

  21. async void button1_Click(…) { await DoWorkAsync(); } async void button1_Click(…)

    { DoWorkAsync().Wait(); } async Task DoWorkAsync() { await Task.Run(…); Console.WriteLine("Done task"); } 1. DoWorkAsync invoked on the main thread 3. Await captures SynchronizationContext and hooks up a continuation to run when task completes 4. Main thread blocks waiting for DoWorkAsync-returned Task to complete 6. UI thread still blocked waiting for async operation to complete. Deadlock! .ConfigureAwait(false) avoids deadlock. async Task DoWorkAsync() { await Task.Run(…).ConfigureAwait(false); Console.WriteLine("Done task"); } 2. Task.Run schedules work to run on thread pool 5. Task.Run task completes on pool & invokes continuation which Posts back to main thread
  22. None
  23. http://tugberkugurlu/131 http://channel9.msdn.com/Events/aspConf/aspConf/Async- in-ASP-NET http://blogs.msdn.com/b/pfxteam http://channel9.msdn.com/Events/Build/2012/3-011

  24. None