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
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();
            }
        }
Beispiel #2
0
 // As long as recording = true keep this event active
 private void video_NewFrame(object sender, AForge.Video.NewFrameEventArgs eventArgs)
 {
     try
     {
         if (rec)
         {
             framecount++;
             writer.WriteVideoFrame(eventArgs.Frame);
         }
         else
         {
             stopWatch.Reset();
             Thread.Sleep(500);
             streamVideo.SignalToStop();
             Thread.Sleep(500);
             writer.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }