void OnPayloadReceived(object sender, Misc.PayloadReceivedEventArgs e) { var msg = e.Payload; if (msg.EventType == "TIMER") { if (msg.Event == "CALL_START") { Started?.Invoke(this, new EventArgs()); } if (msg.Event == "CALL_START_PAUSE") { Paused?.Invoke(this, new EventArgs()); } if (msg.Event == "CALL_END_PAUSE") { Unpaused?.Invoke(this, new EventArgs()); } if (msg.Event == "CALL_END") { Stopped?.Invoke(this, new EventArgs()); } if (msg.Event == "CALL_CANCEL") { Canceled?.Invoke(this, new EventArgs()); } } }
void OnClosing(object sender, ClosingEventArgs e) { lock (_lock) { // allow the dialog to close if the form is closed if (_isClosed) { return; } // do not close if cannot or aborted if (!CanCancel || AbortCanceling()) { e.Ignore = true; return; } // flag _isCanceled = true; // abort if (_jobThread != null) { Pfz.Threading.SafeAbort.Abort(_jobThread, 4000, 2000, 1000, true); } // notify Canceled?.Invoke(this, null); } }
public CustomDialog() { InitializeComponent(); // Background pressed var tgr = new TapGestureRecognizer { NumberOfTapsRequired = 1 }; tgr.Tapped += async(sender, args) => { if (this.CloseWhenBackgroundIsClicked) { await PopupNavigation.Instance.PopAsync(); } }; var views = new View[] { rlBackground, rlBackground2, rlBackground3, rlBackground4 }; foreach (var view in views) { view.GestureRecognizers.Add(tgr); } button.Clicked += async(sender, args) => { await PopupNavigation.Instance.PopAsync(); Canceled?.Invoke(this, new EventArgs()); }; }
//private: void ThreadProc() { try { bool done = DoWork(); State = JobState_t.Finished; if (done) { Succeeded?.Invoke(this); } else { Canceled?.Invoke(this); } } catch (Exception ex) { State = JobState_t.Finished; Aborted?.Invoke(this, ex); } Aborted = null; Canceled = Succeeded = null; }
public ProgressDialogController(MahApps.Metro.Controls.Dialogs.ProgressDialogController wrapped) { _wrapped = wrapped; _wrapped.Canceled += (sender, args) => Canceled.Raise(this); _wrapped.Closed += (sender, args) => Closed.Raise(this); _progress = _wrapped.Minimum; }
internal void HandleTouchCancel(TouchState touch) { if (isRemoved || !IsTouchEnabled()) { return; } if (!HasTouch(touch.id)) { return; } if (HitTestPoint(touch.position)) { return; } _touches.RemoveAt(GetTouchIndex(touch.id)); _isPressed = _touches.Count > 0; TouchCanceled.Dispatch(this, touch); if (_touches.Count == 0) { Canceled.Dispatch(this); } }
protected override async Task PushNext(OrderChange obj) { var ch = obj.Clone(); await base.PushNext(obj); var e = new OrderChangeEventArgs(ch); switch (ch.Type) { case OrderEventType.Canceled: Canceled?.Invoke(this, e); break; case OrderEventType.Filled: Filled?.Invoke(this, e); break; case OrderEventType.Match: Match?.Invoke(this, e); break; case OrderEventType.Open: Open?.Invoke(this, e); break; case OrderEventType.Update: Update?.Invoke(this, e); break; } }
// ダウンロード完了 private void OnDownloadCompleted(Task <DownloadOperation> prevTask) { if (prevTask.IsFaulted) { Debug.WriteLine("キャッシュ失敗"); Failed?.Invoke(this, EventArgs.Empty); return; } Debug.WriteLine("キャッシュ完了"); if (prevTask.Result != null) { var op = DownloadOperation; if (op.Progress.Status == BackgroundTransferStatus.Completed) { if (op.Progress.TotalBytesToReceive == op.Progress.BytesReceived) { Debug.WriteLine("キャッシュ済み: " + op.ResultFile.Name); Completed?.Invoke(this, EventArgs.Empty); } else { Debug.WriteLine("キャッシュキャンセル: " + op.ResultFile.Name); Canceled?.Invoke(this, EventArgs.Empty); } } else { Debug.WriteLine($"キャッシュ失敗: {op.ResultFile.Name} "); Failed?.Invoke(this, EventArgs.Empty); } } }
private void BtnCancel_Click(object sender, RoutedEventArgs e) { Canceled?.Invoke(this, e); var btnCancel = sender as Button; btnCancel.IsEnabled = false; }
public CollectionRenameView() { InitializeComponent(); textBox_newCollectionName.TextChanged += (s, a) => CollectionNameChanged?.Invoke(this, EventArgs.Empty); button_rename.Click += (s, a) => Submited?.Invoke(this, EventArgs.Empty); button_cancel.Click += (s, a) => Canceled?.Invoke(this, EventArgs.Empty); }
void OnDismissed(object sender, EventArgs e) { if (!IsAccepted) { Canceled?.Invoke(this, EventArgs.Empty); } Unrealize(); }
public void Cancel() { Canceled.Reset(); _backgroundProcessor.CancelAsync(); Canceled.WaitOne(); Done.Reset(); Canceled.Reset(); }
private void OnCancelClicked(object sender, EventArgs e) { OnCancel(); TaskPaneArgs args = new TaskPaneArgs(); Canceled?.Invoke(this, args); Visible = args.KeepOpen; }
public void FireCanceledEvent(object source) { if (!canceledEventFired) { Canceled?.Invoke(source, new EventArgs.AsyncTaskEventArgs(this)); canceledEventFired = true; } }
private void _viewModel_Canceled(string message) { if (!string.IsNullOrEmpty(message)) { MessageBox.Show(message); } Canceled?.Invoke(message); }
internal void OnCanceled(object sender, ListingProgressArgs args) { ErrorMessages.Add(string.Format("Listing canceled: {0}", args.Exception.Message)); if (Canceled != null) { Canceled.Invoke(sender, args); } }
/// <summary> /// Defines the method to be called when the command is invoked. /// </summary> /// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can /// be set to null.</param> /// <param name="ignoreCanExecuteCheck">if set to <c>true</c>, the check on <see cref="Command{TExecuteParameter, TCanExecuteParameter}.CanExecute()" /> will be used before /// actually executing the action.</param> protected override async void Execute(TExecuteParameter parameter, bool ignoreCanExecuteCheck) { // Double check whether execution is allowed, some controls directly call Execute if (_execute == null || IsExecuting || (!ignoreCanExecuteCheck && !CanExecute(parameter))) { return; } var args = new CommandCanceledEventArgs(parameter); Executing.SafeInvoke(this, args); if (args.Cancel) { return; } if (_cancellationTokenSource != null) { _cancellationTokenSource.Dispose(); } _cancellationTokenSource = new CancellationTokenSource(); RaiseCanExecuteChanged(); var executionTask = _execute(parameter, _cancellationTokenSource.Token, _progress); try { Log.Info("Executing task command..."); await executionTask.ConfigureAwait(false); } catch (OperationCanceledException) { Log.Info("Task was canceled."); } catch (Exception ex) { Log.Error(ex, "Task ended with exception."); } finally { _cancellationTokenSource.Dispose(); _cancellationTokenSource = null; } if (executionTask.IsCanceled || executionTask.IsFaulted) { Canceled.SafeInvoke(this, new CommandEventArgs(parameter)); } else { RaiseExecuted(parameter); } RaiseCanExecuteChanged(); }
private void FinishCommand_Execute() { if (!IsCanceled) { TryRunApplication(); } Canceled?.Invoke(); }
public override void ViewDidDisappear(bool animated) { base.ViewDidDisappear(animated); if ((IsBeingDismissed || IsMovingFromParentViewController) && !_finishedPickingAssets) { Canceled?.Invoke(this, EventArgs.Empty); } }
public void Dismiss(object sender, EventArgs args) { // Explicitly unregister observers because we cannot predict when the GC cleans up Unregister(); Canceled?.Invoke(this, EventArgs.Empty); PresentingViewController.DismissViewController(true, null); }
private void Abort() { if (WrappedDialog.IsCancelable) { WrappedDialog.PART_NegativeButton.IsEnabled = false; IsCanceled = true; Canceled?.Invoke(this, EventArgs.Empty); } }
private void PART_NegativeButton_Click(object sender, RoutedEventArgs e) { WrappedDialog.Invoke(() => { IsCanceled = true; Canceled?.Invoke(this, EventArgs.Empty); WrappedDialog.PART_NegativeButton.IsEnabled = false; }); }
/// <summary> /// Defines the method to be called when the command is invoked. /// </summary> /// <param name="parameter">Data used by the command. If the command does not require data to be passed, this object can be set to null.</param> /// <param name="ignoreCanExecuteCheck">if set to <c>true</c>, the check on <see cref="System.Windows.Input.ICommand.CanExecute"/> will be used before actually executing the action.</param> protected override async void Execute(TExecuteParameter parameter, bool ignoreCanExecuteCheck) { if (IsExecuting) { return; } // It might be possible that the IsExecuting is used as a check whether the command can be executed again, // so use that as a check var canExecute = CanExecute(parameter); if (!canExecute) { return; } var args = new CommandCanceledEventArgs(parameter); Executing.SafeInvoke(this, args); if (args.Cancel) { return; } IsExecuting = true; RaiseCanExecuteChanged(); // Run the action on a new thread from the thread pool (this will therefore work in Silverlight and Windows Phone as well) #if NETFX_CORE await ThreadPool.RunAsync(state => #else ThreadPool.QueueUserWorkItem(state => #endif { // Skip the check, we already did that base.Execute(parameter, true); ReportProgress(() => { IsExecuting = false; if (IsCancelationRequested) { Canceled.SafeInvoke(this, () => new CommandEventArgs(parameter)); } else { RaiseExecuted(parameter); } IsCancelationRequested = false; }); }); }
public void Cancel() { var tsk = TokenSource; if (tsk != null && !tsk.IsCancellationRequested) { tsk.Cancel(); Canceled?.Invoke(this); } }
internal async void Cancel(CoreDispatcher uiDispatcher) { using (var releaser = await _Lock.LockAsync()) { _IsRunning = false; _IsLastTaskCompleted = false; } Canceled?.Invoke(this, this); }
internal void OnCanceled(object sender, TransferFileProgressArgs args) { RemoveActiveTransfer(args.FilePath); ErrorMessages.Add(string.Format("{0} canceled: {1}", args.FilePath, args.Exception.Message)); if (Canceled != null) { Canceled.Invoke(sender, args); } if (Monitor != null) { Monitor.TransferCanceled(this, args); } }
/// <summary> /// Handles the Cancel button click event. /// </summary> /// <returns>A task that represents the asynchronous operation.</returns> protected Task OnCancelClicked() { return(InvokeAsync(async() => { await ModalRef.Hide(); if (IsConfirmation && Callback != null) { await InvokeAsync(() => Callback.SetResult(false)); } await Canceled.InvokeAsync(); })); }
public void Cancel() { int refund = paidCost.ManaValue; if (castingState == CastingState.CardCast) { Canceled?.Invoke(new CastingEventArgs(stagedCard, refund)); } else if (castingState == CastingState.Ability) { Canceled?.Invoke(new CastingEventArgs(stagedCard, stagedAbility, refund)); } cleanup(); }
/// <inheritdoc/> protected override void OnClosing(CancelEventArgs e) { e.Cancel = true; if (_shouldSave) { Saved?.Invoke(this, EventArgs.Empty); } else { Canceled?.Invoke(this, EventArgs.Empty); } _shouldSave = false; Hide(); }
public void RunAsync(Config config) { Done.Reset(); Canceled.Reset(); if (_processor.SamplesCount < 2) { throw new InvalidOperationException(string.Format("Minimum two samples are required; {0} is given.", _processor.SamplesCount)); } if (_backgroundProcessor.IsBusy) { Cancel(); } _backgroundProcessor.RunWorkerAsync(config); }