internal override void Run(Task completedTask, bool canInlineContinuationTask) { // For the base AwaitTaskContinuation, we allow inlining if our caller allows it // and if we're in a "valid location" for it. See the comments on // IsValidLocationForInlining for more about what's valid. For performance // reasons we would like to always inline, but we don't in some cases to avoid // running arbitrary amounts of work in suspected "bad locations", like UI threads. if (canInlineContinuationTask && IsValidLocationForInlining) { RunCallback(GetInvokeActionCallback(), Action, ref Task.InternalCurrent); // any exceptions from Action will be handled by s_callbackRunAction } else { // We couldn't inline, so now we need to schedule it ThreadPoolAdapter.QueueWorkItem(this); } }
internal static void UnsafeScheduleAction(Action action) { var atc = new AwaitTaskContinuation(action, /*flowExecutionContext:*/ false); ThreadPoolAdapter.QueueWorkItem(atc); }