private void checkButton_Click(object sender, RoutedEventArgs e) { switch (bw.Status) { case WorkerStatus.Idle: stop = false; Globals.LogInfo(Components.ProxyManager, "Disabling the UI and starting the checker"); checkButton.Content = "ABORT"; botsSlider.IsEnabled = false; bw.RunWorkerAsync(); bw.Status = WorkerStatus.Running; break; case WorkerStatus.Running: stop = true; Globals.LogWarning(Components.ProxyManager, "Abort signal sent"); checkButton.Content = "HARD ABORT"; bw.Status = WorkerStatus.Stopping; break; case WorkerStatus.Stopping: Globals.LogWarning(Components.ProxyManager, "Hard abort signal sent"); bw.CancelAsync(); break; } }
private void startDebuggerButton_Click(object sender, RoutedEventArgs e) { switch (debugger.Status) { case WorkerStatus.Idle: if (vm.View == StackerView.Blocks) { vm.LS.FromBlocks(vm.GetList()); } else { vm.LS.Script = loliScriptEditor.Text; } if (debuggerTabControl.SelectedIndex == 1) { logRTB.Focus(); } vm.ControlsEnabled = false; if (!OB.OBSettings.General.PersistDebuggerLog) { logRTB.Clear(); } dataRTB.Document.Blocks.Clear(); if (!debugger.IsBusy) { debugger.RunWorkerAsync(); OB.Logger.LogInfo(Components.Stacker, "Started the debugger"); } else { OB.Logger.LogError(Components.Stacker, "Cannot start the debugger (busy)"); } startDebuggerButton.Content = "Abort"; debugger.Status = WorkerStatus.Running; break; case WorkerStatus.Running: if (debugger.IsBusy) { debugger.CancelAsync(); OB.Logger.LogInfo(Components.Stacker, "Sent Cancellation Request to the debugger"); } startDebuggerButton.Content = "Force"; debugger.Status = WorkerStatus.Stopping; break; case WorkerStatus.Stopping: debugger.Abort(); OB.Logger.LogInfo(Components.Stacker, "Hard aborted the debugger"); startDebuggerButton.Content = "Start"; debugger.Status = WorkerStatus.Idle; vm.ControlsEnabled = true; break; } }
private void _CancelWorker(object parameter) { if (_WorkerUi != null) { if (_WorkerUi.WorkerSupportsCancellation && _WorkerUi.CancellationPending || !_WorkerUi.WorkerSupportsCancellation) { _WorkerAbort(ref _WorkerUi); } else if (_WorkerUi.WorkerSupportsCancellation && _WorkerUi.IsBusy) { _WorkerUi.CancelAsync(); } } }
/// <summary> /// Destroy this component /// </summary> public override void Destroy() { base.Destroy(); // Sets IsDestroying flag try { if (_iSensor != 0) { if (_hSensorDataReady != 0) { // Complete worker thread MEDAQLibDLL.SetEvent(_hSensorDataReady); Thread.Sleep(50); } MEDAQLibDLL.CloseSensor(_iSensor); MEDAQLibDLL.ReleaseSensorInstance(_iSensor); } if (_bw != null) { if (_bw.IsBusy) { _bw.CancelAsync(); } _bw.Dispose(); _bw = null; } } catch (Exception ex) { U.LogError(ex, "Error disposing '{0}'", Nickname); } finally { _bw = null; } }