Example #1
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)
        {
            var handler = Completed;

            if (handler != null)
            {
                handler(this, args);
            }
        }
Example #2
0
            protected override void OnCompleted(OpenFileDialog openFileDialog, CoTaskCompletedEventArgs args)
            {
                if (!args.WasCancelled)
                {
                    Result = openFileDialog.FileNames.Select(name => new FileInfo(name)).ToArray();
                }

                base.OnCompleted(openFileDialog, args);
            }
Example #3
0
            protected override void OnCompleted(OpenFileDialog openFileDialog, CoTaskCompletedEventArgs args)
            {
                if (!args.WasCancelled)
                {
                    Result = new FileInfo(openFileDialog.FileName);
                }

                base.OnCompleted(openFileDialog, args);
            }
Example #4
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 != null || !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.Light.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 == null)
            {
                OnCompleted(args);
            }
            else
            {
                Rescue(context, error);
            }
        }
        private void ChildCompleted(object sender, CoTaskCompletedEventArgs args)
        {
            var previous = sender as ICoTask;

            if (previous != null)
            {
                previous.Completed -= ChildCompleted;
            }

            if (args.Error != null || 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);
            }
        }
Example #7
0
 private void ContinueCompleted(object sender, CoTaskCompletedEventArgs args)
 {
     ((ICoTask) sender).Completed -= ContinueCompleted;
     OnCompleted(new CoTaskCompletedEventArgs(args.Error, args.Error == null));
 }
 private void RescueCompleted(object sender, CoTaskCompletedEventArgs args)
 {
     ((ICoTask)sender).Completed -= RescueCompleted;
     OnCompleted(new CoTaskCompletedEventArgs(args.Error,
                                              args.Error == null && (args.WasCancelled || _cancelCoTask)));
 }
Example #9
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);
Example #10
0
 private void InnerCoTaskCompleted(object sender, CoTaskCompletedEventArgs args)
 {
     _innerCoTask.Completed -= InnerCoTaskCompleted;
     OnInnerResultCompleted(_context, _innerCoTask, args);
     _context = null;
 }
Example #11
0
 /// <summary>
 /// Handles the completion of the execution.
 /// </summary>
 /// <param name="openFileDialog">The open file dialog.</param>
 /// <param name="args">The <see cref="CoTaskCompletedEventArgs"/> instance containing the event data.</param>
 protected virtual void OnCompleted(OpenFileDialog openFileDialog, CoTaskCompletedEventArgs args)
 {
     OnCompleted(args);
 }