Проблема в том, что продолжению может потребоваться доступ к однопоточным частям библиотеки, что означает, что оно должно выполняться в том же цикле событий. Например, в простом игровом цикле события могут обрабатываться следующим образом:
Код: Выделить всё
// All continuation calls should be put onto this queue
Queue events;
// The main thread calls the `Update` method continuously on each "frame"
void Update() {
// All accumulated events are processed in order and the queue is cleared
foreach (var event : events) Process(event);
events.Clear();
}
Код: Выделить всё
async void Foo() {
someLabel.Text = "Processing";
await BackgroundTask();
// This has to execute on the main thread
someLabel.Text = "Done";
}
Подробнее здесь: https://stackoverflow.com/questions/392 ... ons-can-be