AForge.Video.ScreenCaptureStream.SignalToStop C# (CSharp) Method

SignalToStop() public method

Signal video source to stop its work.
Signals video source to stop its background thread, stop to provide new frames and free resources.
public SignalToStop ( ) : void
return void
		public void SignalToStop( )
		{
			// stop thread
			if ( thread != null )
			{
				// signal to stop
				stopEvent.Set( );
			}
		}

Usage Example

Beispiel #1
0
        private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            try
            {
                if (rec)
                {
                    frameCount++;
                    writer.WriteVideoFrame(eventArgs.Frame);
                    lb_1.Invoke(new Action(() =>
                    {
                        lb_1.Text = "Frames: " + frameCount.ToString();
                    }));
                    lb_stopWatch.Invoke(new Action(() =>
                    {
                        lb_stopWatch.Text = stopWatch.Elapsed.ToString();
                    }));
                }
                else
                {
                    // End of recording
                    #region video
                    stopWatch.Reset();
                    Thread.Sleep(500);
                    streamVideo.SignalToStop();
                    Thread.Sleep(500);
                    writer.Close();
                    #endregion video

                    #region audio
                    stopRecordMp3();
                    #endregion audio

                    if (bCaptureVideo)
                    {
                        AddMP3toAVI(aviFileName, mp3FileName);
                    }
                    else
                    {
                        try {
                            File.Delete(aviFileName);
                        }
                        catch (Exception er)
                        {
                            Console.Write(er.Message);
                        }
                    }
                }
            }
            catch (Exception glj)
            {
                MessageBox.Show(glj.Message);
                resetValues();
            }
        }
All Usage Examples Of AForge.Video.ScreenCaptureStream::SignalToStop