internal void Abort(Exception ex)
        {
            if (_Future != null)
            {
                _Future.Fail(ex);
            }

            Dispose();
        }
Ejemplo n.º 2
0
 void Completed(IFuture f)
 {
     if (f.Failed)
     {
         _CompletionSignal.Fail(f.Error);
     }
     else
     {
         _CompletionSignal.Complete();
     }
 }
Ejemplo n.º 3
0
        void HandleResult(IFuture wait)
        {
            var errors = (from f in _Futures where f.Failed select f.Error).ToArray();

            if (errors.Length == 0)
            {
                _ResultFuture.Complete();
            }
            else
            {
                _ResultFuture.Fail(new WaitForAllException(errors));
            }
        }
Ejemplo n.º 4
0
 void ISchedulable.Schedule(TaskScheduler scheduler, IFuture future)
 {
     _SleepFuture = scheduler.Start(new Sleep(_Timeout));
     _TaskFuture  = Future.WaitForFirst(_Future, _SleepFuture);
     _TaskFuture.RegisterOnComplete((f) => {
         if (f.Result == _SleepFuture)
         {
             future.Fail(new TimeoutException("WaitWithTimeout timed out."));
         }
         else
         {
             future.Complete();
         }
     });
 }
Ejemplo n.º 5
0
        protected void Fail(Exception error)
        {
            OnEarlyDispose = null;

            if (_ResumeFuture != null)
            {
                _ResumeFuture.Fail(error);
                _ResumeFuture = null;
            }

            if ((_SequenceFuture != null) && (!_SequenceFuture.Completed))
            {
                _SequenceFuture.Fail(error);
            }

            Dispose();
        }
Ejemplo n.º 6
0
 public static void BindFuture(this tTask task, IFuture future)
 {
     task.GetAwaiter().OnCompleted(() => {
         // FIXME: ExceptionDispatchInfo?
         if (task.IsFaulted)
         {
             future.Fail(task.Exception.InnerExceptions.Count == 1 ? task.Exception.InnerException : task.Exception);
         }
         else
         {
             future.Complete();
         }
     });
     future.RegisterOnDispose((_) => {
         task.TryCancelScope();
     });
 }
Ejemplo n.º 7
0
        public static void BindFuture(this tTask task, IFuture future)
        {
            if (task.IsCompleted && !task.IsFaulted)
            {
                future.Complete();
                return;
            }

            task.ConfigureAwait(false).GetAwaiter().OnCompleted(() => {
                // FIXME: ExceptionDispatchInfo?
                if (task.IsFaulted)
                {
                    future.Fail(task.Exception.InnerExceptions.Count == 1 ? task.Exception.InnerException : task.Exception);
                }
                else
                {
                    future.Complete();
                }
            });
            future.RegisterOnDispose(CancelScopeForTask, task);
        }
Ejemplo n.º 8
0
 public override void Fail(Exception ex)
 {
     Future.Fail(ex);
 }