diff --git a/src/mscorlib/src/System/Threading/Tasks/Task.cs b/src/mscorlib/src/System/Threading/Tasks/Task.cs index 6d4ddf8473c3..5fc1d22779f9 100644 --- a/src/mscorlib/src/System/Threading/Tasks/Task.cs +++ b/src/mscorlib/src/System/Threading/Tasks/Task.cs @@ -542,10 +542,6 @@ internal void TaskConstructorCore(Delegate action, object state, CancellationTok m_stateObject = state; m_taskScheduler = scheduler; - Debug.Assert(m_contingentProperties == null || m_contingentProperties.m_capturedContext == null, - "Captured an ExecutionContext when one was already captured."); - CapturedContext = ExecutionContext.Capture(); - // Check for validity of options if ((creationOptions & ~(TaskCreationOptions.AttachedToParent | @@ -602,6 +598,10 @@ internal void TaskConstructorCore(Delegate action, object state, CancellationTok AssignCancellationToken(cancellationToken, null, null); } + + Debug.Assert(m_contingentProperties == null || m_contingentProperties.m_capturedContext == null, + "Captured an ExecutionContext when one was already captured."); + CapturedContext = ExecutionContext.Capture(); } ///