diff options
Diffstat (limited to 'mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs')
-rw-r--r-- | mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs b/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs index fa6b3d92ca8..5c6833f33e7 100644 --- a/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs +++ b/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs @@ -825,16 +825,28 @@ namespace System.Runtime.CompilerServices // so that they won't "leak" out of the first await. Thread currentThread = Thread.CurrentThread; +#if MONO + ExecutionContext.Switcher ecs = default (ExecutionContext.Switcher); +#else ExecutionContextSwitcher ecs = default(ExecutionContextSwitcher); +#endif RuntimeHelpers.PrepareConstrainedRegions(); try { +#if MONO + currentThread.BranchExecutionContext (out ecs); +#else ExecutionContext.EstablishCopyOnWriteScope(currentThread, false, ref ecs); +#endif stateMachine.MoveNext(); } finally { +#if MONO + currentThread.RestoreExecutionContext (ref ecs); +#else ecs.Undo(currentThread); +#endif } } |