AForge.Video.DirectShow.VideoCaptureDevice.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

Ejemplo n.º 1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (button2.Text == "Tomar Foto")
     {
         AForge.Video.DirectShow.FilterInfoCollection videosources = new AForge.Video.DirectShow.FilterInfoCollection(AForge.Video.DirectShow.FilterCategory.VideoInputDevice);
         if (videosources != null)
         {
             videosource           = new AForge.Video.DirectShow.VideoCaptureDevice(videosources[0].MonikerString);
             videosource.NewFrame += (s, a) => pictureBox2.Image = (Bitmap)a.Frame.Clone();
             videosource.Start();
             button2.Text = "Capturar";
         }
     }
     else
     {
         pictureBox1.Image = pictureBox2.Image;
         if (videosource != null && videosource.IsRunning)
         {
             videosource.SignalToStop();
             videosource = null;
         }
         pictureBox2.Image = null;
         button2.Text      = "Tomar Foto";
     }
 }
All Usage Examples Of AForge.Video.DirectShow.VideoCaptureDevice::SignalToStop