public void Start() { logger.Debug("ScreenSource::Start()"); if (!(state == CaptureState.Stopped || state == CaptureState.Initialized)) { throw new InvalidOperationException("Invalid capture state " + State); } // State = CaptureState.Starting; captureTask = Task.Run(() => { try { logger.Info("Capture thread started..."); CaptureStarted?.Invoke(); DoCapture(); } catch (Exception ex) { logger.Error(ex); LastError = ex; errorCode = (int)SharedTypes.ErrorCode.Unexpected; } finally { CaptureStopped?.Invoke(null); logger.Info("Capture thread stopped..."); } }); }
private void OnCaptureStopped() { syncContext.Send(_ => { if (DebugMode) { switchCaptureStateButton.Text = "_Start"; switchCaptureStateButton.Enabled = true; comboBoxDevices.Enabled = true; comboBoxDisplayModes.Enabled = true; findServiceButton.Enabled = true; statusLabel2.Text = "_CaptureStopped"; } this.timer.Enabled = false; isCapture = false; CaptureStopped?.Invoke(); }, null); }
public void Start() { logger.Debug("AudioSource::Start()"); if (!(captureState == CaptureState.Stopped || captureState == CaptureState.Initialized)) { throw new InvalidOperationException("Previous recording still in progress"); } captureState = CaptureState.Starting; captureTask = Task.Run(() => { try { logger.Info("Capture thread started..."); captureState = CaptureState.Capturing; CaptureStarted?.Invoke(); DoCapture(); } catch (Exception ex) { logger.Error(ex); this.ErrorCode = 100500; } finally { logger.Info("Capture thread stopped..."); captureState = CaptureState.Stopped; CaptureStopped?.Invoke(null); } }); }