{
Debug.Assert(stateMachineBox != null);
+ // This code path doesn't emit all expected TPL-related events, such as for continuations.
+ // It's expected that all callers check whether events are enabled before calling this function,
+ // and only call it if they're not, so we assert. However, as events can be dynamically turned
+ // on and off, it's possible this assert could fire even when used correctly. If it becomes
+ // noisy, it can be deleted.
+ Debug.Assert(!TplEventSource.Log.IsEnabled());
+
// If the caller wants to continue on the current context/scheduler and there is one,
// fall back to using the state machine's delegate.
if (continueOnCapturedContext)
}
}
- // Otherwise, add the state machine box directly as the ITaskCompletionAction continuation.
- // If we're unable to because the task has already completed, queue the delegate.
+ // Otherwise, add the state machine box directly as the continuation.
+ // If we're unable to because the task has already completed, queue it.
if (!AddTaskContinuation(stateMachineBox, addBeforeOthers: false))
{
- AwaitTaskContinuation.UnsafeScheduleAction(stateMachineBox.MoveNextAction, this);
+ Debug.Assert(stateMachineBox is Task, "Every state machine box should derive from Task");
+ ThreadPool.UnsafeQueueUserWorkItemInternal(stateMachineBox, preferLocal: true);
}
}