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 OnCaptureStarted() { syncContext.Send(_ => { if (DebugMode) { this.switchCaptureStateButton.Enabled = true; this.switchCaptureStateButton.Text = "_Stop"; statusLabel2.Text = "_CaptureStarted"; } this.timer.Enabled = true; isCapture = true; CaptureStarted?.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); } }); }
/// <summary> /// Raises the <see cref="CaptureStarted"/> event. /// </summary> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void RaiseCaptureStarted(EventArgs e) { CaptureStarted?.Invoke(this, e); }