5* Hotel Call Girls In Goa 7028418221 Call Girls In North Goa Escort Services
The zen of async: Best practices for best performance
1.
2. WHO WILL BENEFIT FROM THIS
TOPICS WHAT YOU’LL LEAVE WITH
TALK
• .NET library developers : • Getting the Right Mental Model • Knowledge of:
• with knowledge of • Knowing When Not To Use Async • when to care about
async/await in C# / VB optimizing your async
• Avoiding Allocations implementations
• interested in low-level perf
• Caring About Context • …and how to do it
• that understand this is
based on the Developer • Minimizing Suspensions
Preview
21. User’s app Your library
async void button1_Click(…) async Task DoWorkAsync()
{ {
DoWorkAsync().Wait();
await DoWorkAsync(); await Task.Run(…);
Task.Run(…).ConfigureAwait(false);
} Console.WriteLine("Done task");
}
3. Await captures
1. DoWorkAsync 2. Task.Run schedules work
SynchronizationContext and
invoked on UI thread to run on thread pool
4. UI blocks waiting for hooks up a continuation to run
DoWorkAsync-returned when task completes
Task to complete
5. Task.Run task completes on pool & invokes
6. UI thread still blocked continuation which Posts back to UI thread
waiting for async
operation to complete.
Deadlock! .ConfigureAwait(false) avoids deadlock.
22. Demo
Library implementers should
use ConfigureAwait(false) to
improve performance and to
help avoid deadlocks.