private void Suspend(Task local, IAwaiter a) { Move(ref _runningTasks, ref _suspendedTasks, local); a.OnCompleted(() => { // タイマーとかの OnCompleted 待ちすることもあるので、 // この中、別スレッドで呼ばれる可能性あり。 if (_status != TaskSchedulerStatus.ShutdownTimeout) { Move(ref _suspendedTasks, ref _runningTasks, local); } }); }
/// <summary>Schedules the continuation action that's invoked when the instance completes.</summary> /// <param name="continuation">The action to invoke when the operation completes.</param> public void OnCompleted(Action continuation) { if (_asyncOp == null) { Task.Run(continuation); return; } IAwaiter <TResult> awaiter = _asyncOp as IAwaiter <TResult>; if (awaiter != null) { awaiter.OnCompleted(continuation); return; } Task <TResult> task = (Task <TResult>)_asyncOp; task.GetAwaiter().OnCompleted(continuation); }
public void UnsafeOnCompleted(Action continuation) => _awaiter.OnCompleted(continuation);
public void OnCompleted(Action continuation) { awaiter.OnCompleted(continuation); }