Merge pull request #18889 from madadam/async-await-fix

Set current SynchronizationContext before the game loop starts
This commit is contained in:
Ignacio Etcheverry 2018-05-16 23:44:55 +02:00 committed by GitHub
commit 41f79a6f14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -14,6 +14,7 @@ namespace Godot
public GodotTaskScheduler() public GodotTaskScheduler()
{ {
Context = new GodotSynchronizationContext(); Context = new GodotSynchronizationContext();
SynchronizationContext.SetSynchronizationContext(Context);
} }
protected sealed override void QueueTask(Task task) protected sealed override void QueueTask(Task task)
@ -57,7 +58,6 @@ namespace Godot
public void Activate() public void Activate()
{ {
SynchronizationContext.SetSynchronizationContext(Context);
ExecuteQueuedTasks(); ExecuteQueuedTasks();
Context.ExecutePendingContinuations(); Context.ExecutePendingContinuations();
} }