Ejemplo n.º 1
0
        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);
                }
            });
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 public void UnsafeOnCompleted(Action continuation) => _awaiter.OnCompleted(continuation);
Ejemplo n.º 4
0
 public void OnCompleted(Action continuation)
 {
     awaiter.OnCompleted(continuation);
 }