Exemplo n.º 1
0
 /// <summary>
 /// Called when the execution of the decorated CoTask has completed.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="innerCoTask">The decorated CoTask.</param>
 /// <param name="args">The <see cref="CoTaskCompletedEventArgs" /> instance containing the event data.</param>
 protected override void OnInnerResultCompleted(CoroutineExecutionContext context, ICoTask innerCoTask,
                                                CoTaskCompletedEventArgs args)
 {
     if (args.Error is object || !args.WasCancelled)
     {
         OnCompleted(new CoTaskCompletedEventArgs(args.Error, false));
     }
     else
     {
         Continue(context);
     }
 }
        /// <summary>
        /// Called when the execution of the decorated CoTask has completed.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="innerCoTask">The decorated coTask.</param>
        /// <param name="args">The <see cref="Caliburn.Coroutines.CoTaskCompletedEventArgs" /> instance containing the event data.</param>
        protected override void OnInnerResultCompleted(CoroutineExecutionContext context, ICoTask innerCoTask,
                                                       CoTaskCompletedEventArgs args)
        {
            var error = args.Error as TException;

            if (error is null)
            {
                OnCompleted(args);
            }
            else
            {
                Rescue(context, error);
            }
        }
Exemplo n.º 3
0
        private void ChildCompleted(object sender, CoTaskCompletedEventArgs args)
        {
            var previous = sender as ICoTask;

            if (previous is object)
            {
                previous.Completed -= ChildCompleted;
            }

            if (args.Error is object || args.WasCancelled)
            {
                OnComplete(args.Error, args.WasCancelled);
                return;
            }

            bool moveNextSucceeded;

            try
            {
                moveNextSucceeded = _enumerator.MoveNext();
            }
            catch (Exception ex)
            {
                OnComplete(ex, false);
                return;
            }

            if (moveNextSucceeded)
            {
                try
                {
                    var next = _enumerator.Current;
                    next.Completed += ChildCompleted;
                    next.BeginExecute(_context);
                }
                catch (Exception ex)
                {
                    OnComplete(ex, false);
                }
            }
            else
            {
                OnComplete(null, false);
            }
        }
Exemplo n.º 4
0
 private void ContinueCompleted(object sender, CoTaskCompletedEventArgs args)
 {
     ((ICoTask)sender).Completed -= ContinueCompleted;
     OnCompleted(new CoTaskCompletedEventArgs(args.Error, args.Error is null));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Raises the <see cref="Completed" /> event.
 /// </summary>
 /// <param name="args">The <see cref="CoTaskCompletedEventArgs"/> instance containing the event data.</param>
 protected void OnCompleted(CoTaskCompletedEventArgs args)
 {
     Completed?.Invoke(this, args);
 }
Exemplo n.º 6
0
 /// <summary>
 /// Called when the execution of the decorated CoTask has completed.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="innerCoTask">The decorated CoTask.</param>
 /// <param name="args">The <see cref="CoTaskCompletedEventArgs"/> instance containing the event data.</param>
 protected abstract void OnInnerResultCompleted(CoroutineExecutionContext context, ICoTask innerCoTask,
                                                CoTaskCompletedEventArgs args);
Exemplo n.º 7
0
 private void InnerCoTaskCompleted(object sender, CoTaskCompletedEventArgs args)
 {
     _innerCoTask.Completed -= InnerCoTaskCompleted;
     OnInnerResultCompleted(_context, _innerCoTask, args);
     _context = null;
 }
 private void RescueCompleted(object sender, CoTaskCompletedEventArgs args)
 {
     ((ICoTask)sender).Completed -= RescueCompleted;
     OnCompleted(new CoTaskCompletedEventArgs(args.Error,
                                              args.Error is null && (args.WasCancelled || _cancelCoTask)));
 }