multithreading - Do C# await continuations create new threads? -


as question says. i'd know if calling await in code has potential create new thread.

let's assume it's during console app.

microsoft's .net 4.5 task implementation first try invoke await-based continuations inline (i.e., on whatever thread completes task). if can't executed inline (e.g., due stack depth or use of synchronizationcontext) system thread pool used instead. won't explicitly create new thread, though might trigger creation of new thread in pool.

see system.threading.tasks.awaittaskcontinuation in reference sources details.

note answer only applies awaited task, , on microsoft .net 4.5 framework. also, if awaiting thread synchronizationcontext, , not using configureawait(false), depend on synchronizationcontext implementation. no new threads should created winforms, wpf, or silverlight synchronizationcontext.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -