void ChildCompleted(object sender, ResultCompletionEventArgs args) { if(args.Error != null || args.WasCancelled) { OnComplete(args.Error, args.WasCancelled); return; } var previous = sender as IResult; if(previous != null) previous.Completed -= ChildCompleted; var moveNextSucceeded = false; try { moveNextSucceeded = enumerator.MoveNext(); } catch(Exception ex) { OnComplete(ex, false); return; } if(moveNextSucceeded) { try { var next = enumerator.Current; IoC.BuildUp(next); next.Completed += ChildCompleted; next.Execute(context); } catch(Exception ex) { OnComplete(ex, false); return; } } else OnComplete(null, false); }
/// <summary> /// Executes the result using the specified context. /// </summary> /// <param name="context">The context.</param> public void Execute(ActionExecutionContext context) { if (string.IsNullOrEmpty(LastFmDataAccess.ApiKey)) { var args = new ResultCompletionEventArgs { Error = new Exception("Can't execute query. No API-Key found."), WasCancelled = true }; Completed(this, args); EventAgg.Publish(new ErrorMessage(args)); } var stopWatch = new StopWatch(10000); var webClient = new WebClient(); webClient.OpenReadCompleted += (sender, e) => { stopWatch.Stop(); if (e.Error == null) { XDocument doc = XDocument.Load(e.Result); XElement ee = doc.Descendants("error").FirstOrDefault(); if (ee != null) { stopWatch.Stop(); Completed(this, new ResultCompletionEventArgs { Error = new Exception(ee.Value), WasCancelled = false }); return; } XmlResult = doc.Root; if (repository != null && addToRepository != LastFmRepository.RepositoryTypes.None) repository.AddData(XmlResult, addToRepository); Completed(this, new ResultCompletionEventArgs()); return; } var args = new ResultCompletionEventArgs { Error = e.Error, WasCancelled = false }; Completed(this, args); EventAgg.Publish(new ErrorMessage(args)); }; stopWatch.StopWatchEnded += (sender, e) => { var args = new ResultCompletionEventArgs { Error = new TimeoutException("Timeout of " + GetType().Name), WasCancelled = false }; EventAgg.Publish(new ErrorMessage(args)); Completed(this, args); }; stopWatch.Start(); webClient.OpenReadAsync(new Uri(searchString)); }
void IResult.Execute(ActionExecutionContext context) { var dialog = CreateDialog(); if (dialog.ShowDialog() != true) { this.OnCompleted(new ResultCompletionEventArgs { WasCancelled = this._IgnoreUserCancel == false }); return; } var resultArgs = new ResultCompletionEventArgs(); this.FileNames = dialog.FileNames; if (this._FileAction != null) { try { this._FileAction(FileNames); } catch (Exception e) { resultArgs.Error = e; } } this.OnCompleted(resultArgs); }
protected virtual void OnCompleted(ResultCompletionEventArgs e) { var handler = this.Completed; if (handler != null) { handler(this, e); } }
private void OnComplete(Exception error, bool wasCancelled) { this.enumerator.Dispose(); ResultCompletionEventArgs e = new ResultCompletionEventArgs { Error = error, WasCancelled = wasCancelled }; this.Completed(this, e); }
/// <summary> /// Called when the execution of the decorated result has completed. /// </summary> /// <param name="context">The context.</param> /// <param name="innerResult">The decorated result.</param> /// <param name="args">The <see cref="ResultCompletionEventArgs" /> instance containing the event data.</param> protected override void OnInnerResultCompleted(CoroutineExecutionContext context, IResult innerResult, ResultCompletionEventArgs args) { if (args.Error != null || !args.WasCancelled) { OnCompleted(new ResultCompletionEventArgs {Error = args.Error}); } else { Log.Info(string.Format("Executing coroutine because {0} was cancelled.", innerResult.GetType().Name)); Continue(context); } }
public void Execute(ActionExecutionContext context) { var windowManager = IoC.Get<IWindowManager>(); windowManager.ShowDialog(_question); var args = new ResultCompletionEventArgs(); args.WasCancelled = _cancelAnswer.HasValue && _question.GivenAnswer == _cancelAnswer.Value; Completed(this, args); }
private static async void CoroutineOnCompleted(object sender, ResultCompletionEventArgs resultCompletionEventArgs) { var exception = resultCompletionEventArgs.Error as AggregateException; if (exception != null) { await Task.Yield(); throw exception.Flatten().InnerException; } }
/// <summary> /// Executes the result using the specified context. /// </summary> /// <param name="context">The context.</param> public void Execute(CoroutineExecutionContext context) { var eventArgs = new ResultCompletionEventArgs(); try { toExecute(); } catch (Exception ex) { eventArgs.Error = ex; } Completed(this, eventArgs); }
private void ChildCompleted(object sender, ResultCompletionEventArgs args) { IResult result = sender as IResult; if (result != null) { result.Completed -= new EventHandler<ResultCompletionEventArgs>(this.ChildCompleted); } if ((args.Error != null) || args.WasCancelled) { this.OnComplete(args.Error, args.WasCancelled); } else { Exception exception; bool flag = false; try { flag = this.enumerator.MoveNext(); } catch (Exception exception1) { exception = exception1; this.OnComplete(exception, false); return; } if (flag) { try { IResult current = this.enumerator.Current; IoC.BuildUp(current); current.Completed += new EventHandler<ResultCompletionEventArgs>(this.ChildCompleted); current.Execute(this.context); } catch (Exception exception2) { exception = exception2; this.OnComplete(exception, false); } } else { this.OnComplete(null, false); } } }
void IResult.Execute(ActionExecutionContext context) { var result = MessageBox.Show(this._Text, this._Caption, this._Button, this._Icon, this._DefaultResult, this._Options); var resultArgs = new ResultCompletionEventArgs(); this.Result = result; if (this._ResultAction != null) { try { this._ResultAction(result); } catch (Exception e) { resultArgs.Error = e; } } this.OnCompleted(resultArgs); }
public ErrorMessage(ResultCompletionEventArgs completionEventArgs) { CompletionEventArgs = completionEventArgs; }
public ErrorMessage(ResultCompletionEventArgs eventArgs) { EventArgs = eventArgs; }
protected override void InnerCompleted(object sender, ResultCompletionEventArgs args) { base.InnerCompleted(sender, args); Executer.OnUIThread(() => this.OnCompleted(new ResultCompletionEventArgs { WasCancelled = args.WasCancelled, Error = args.Error })); }
/// <summary> /// Raises the <see cref="Completed" /> event. /// </summary> /// <param name="args">The <see cref="ResultCompletionEventArgs"/> instance containing the event data.</param> protected void OnCompleted(ResultCompletionEventArgs args) { Completed(this, args); }
public void DoCompleted(ResultCompletionEventArgs args) { this.Completed(this, args); }
/// <summary> /// Called when the execution of the decorated result has completed. /// </summary> /// <param name="context">The context.</param> /// <param name="innerResult">The decorated result.</param> /// <param name="args">The <see cref="ResultCompletionEventArgs"/> instance containing the event data.</param> protected abstract void OnInnerResultCompleted(CoroutineExecutionContext context, IResult innerResult, ResultCompletionEventArgs args);
protected virtual void OnCompleted(object sender, ResultCompletionEventArgs e) { if (Completed != null) Completed(sender, e); }
protected static void CreateSut(Action action) { Sut = new DelegateResult(action); Sut.Completed += (sender, args) => CompletionArgs = args; }
protected virtual void InnerCompleted(object sender, ResultCompletionEventArgs args) { ((IResult)sender).Completed -= this.InnerCompleted; }
protected virtual void OnCompleted(ResultCompletionEventArgs args) { this.Completed(this, args); }
void ContinueCompleted(object sender, ResultCompletionEventArgs args) { ((IResult)sender).Completed -= ContinueCompleted; OnCompleted(new ResultCompletionEventArgs {Error = args.Error, WasCancelled = (args.Error == null)}); }
protected virtual void OnCompleted(ResultCompletionEventArgs e) { Caliburn.Micro.Execute.OnUIThread(() => Completed(this, e)); }
private void HandleAvailabilityError(object sender, ResultCompletionEventArgs e) { events.Publish(BusyState.NotBusy()); if (e.Error != null) events.Publish(new ErrorState(e.Error, "Could not get station availability.")); }
private void OnCompleted(ResultCompletionEventArgs args) { this._Completed(this, args); }
void InnerResultCompleted(object sender, ResultCompletionEventArgs args) { innerResult.Completed -= InnerResultCompleted; OnInnerResultCompleted(context, innerResult, args); context = null; }