浏览代码

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

Set current SynchronizationContext before the game loop starts
Ignacio Etcheverry 7 年之前
父节点
当前提交
41f79a6f14
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      modules/mono/glue/cs_files/GodotTaskScheduler.cs

+ 1 - 1
modules/mono/glue/cs_files/GodotTaskScheduler.cs

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