Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li><p>If you're using it in the context of async IO it's a moot point. The time spent on your database operation, file/network IO, etc. will be milliseconds at best. The overhead of <code>async</code> will be microseconds at worst, if no nanoseconds. Where you need to be careful is when you have a <em>lot</em> of operations that you are awaiting (as in thousands, tens of thousands, or more) and those operations are <em>very</em> quick. When those async operations represent CPU bound work it's certainly possible for the overhead of using <code>await</code> to be at least noticeable. Note that the code generated for the state machine is somewhat complex, in terms of human understand-ability, but state machines in general tend to perform rather well as a whole.</p></li> <li><p>The methods are not just wrappers that block a thread pool thread, no. That would defeat the purpose of what <code>await</code> represents. Those methods don't block <em>any</em> thread and rely on OS hooks to complete the task.</p></li> <li><p>Sure, you can create your own <code>SynchronizationContext</code> instead of relying entirely on an existing one provided by your UI framework. <a href="http://blogs.msdn.com/b/pfxteam/archive/2012/02/02/await-synchronizationcontext-and-console-apps-part-3.aspx">Here</a> is a great example. Just be careful when using something like this; it's a good tool for the right task, but can be abused to find a more creating way of blocking when you should just be doing everything asynchronously.</p></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload