Continue with the task in the main topic.

Forgive me if this is a simple question; I could not calculate it correctly to find the answer.

Consider this code:

var task = Task.Factory.StartNew(() => Whatever());  
task.ContinueWith(Callback, TaskScheduler.FromCurrentSynchronizationContext())

How exactly is it determined when the callback method will be executed?

Will he wait for the main thread to finish what he is doing at the moment, or will he be called right after the asynchronous call is completed? And will this callback be completed completely before the main thread returns to what it did before?

+4
source share
1 answer

Wait until the main thread completes what it is doing at the moment, or is it called right after the asynchronous call ends?

, . (), "" WPF Windows Forms, , Control.BeginInvoke Dispatcher.BeginInvoke - , "" , .

, , , . , .

+8

All Articles