Exemplo n.º 1
0
        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...");
                }
            });
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
                }
            });
        }
Exemplo n.º 4
0
 /// <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.SafeInvoke(this, e);
 }