Synchronization Behavior of await Expressions
Asynchronous operations usually complete on a different thread than the one making the initial request to perform the operation. You’ve seen this repeatedly when studying the APM, EAP, and TAP patterns earlier in this chapter. This is a direct artifact from the way asynchronous completion of I/O operations is carried out on the thread pool. When dealing with compute bound asynchrony, the background thread that performed the computation will likely also be the one signaling the operation’s completion.
This decoupling from the requestor’s original context has traditionally posed an additional inconvenience, requiring manual synchronization for example to update the UI with the operation’s result. A ...
Get C# 5.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.