multithreading - C# async await and threadpool -
I understand that when async is used and waits on a method called on UI thread That the UI thread can be freed to others, while waiting for something to finish the job, if I wait for the use of async method called a threadbull thread with that thread thread thread, while IO Does it complete? Is it back in the pool? When IO is complete, in the latter case what thread fulfills the method?
If I wait async on a method called a threadbull thread, that thread of thread Happens while IO is complete? Is it returned to the pool?
Yes, the thread pool thread is returned to the thread pool.
When IO is completed, what does the thread accomplish in this latter case?
By default, waiting
will capture an existing "reference", and it will wait for the async
method when
is complete This is the "reference" Synchronization contaxes. Current
Unless it is null
, in that case "context" is functional. Current
.
In the UI case, there is a UI Synchronization Contex
which causes the async
method to execute on the UI thread. In the thread pool case, Synchronization Contains. Current
is null
, and TaskScheduler.Current
is the Thread Pool task scheduler. Therefore, the async
method starts again on the thread pool thread (any arbitrary thread on which there is no single thread).
If you want more information on this behavior, then I can get help from you.
Comments
Post a Comment