public void TestFileCapturePause() { int totalFrames1 = 0; Capture capture1 = new Capture(EmguAssert.GetFile("tree.avi")); //capture one will continute capturing all the frames. EventHandler captureHandle1 = delegate { Mat img = new Mat(); capture1.Retrieve(img); totalFrames1++; Trace.WriteLine(String.Format("capture 1 frame {0}: {1}", totalFrames1, DateTime.Now.ToString())); }; capture1.ImageGrabbed += captureHandle1; capture1.Start(); System.Threading.Thread.Sleep(2); int totalFrames2 = 0; Capture capture2 = new Capture(EmguAssert.GetFile("tree.avi")); int counter = 0; //capture 2 will capture 2 frames, pause for 1 seconds, then continute; EventHandler captureHandle = delegate { counter++; totalFrames2++; bool needPause = (counter >= 2); if (needPause) { capture2.Pause(); counter = 0; } Mat img = new Mat(); capture2.Retrieve(img); Trace.WriteLine(String.Format("capture 2 frame {0}: {1}", totalFrames2, DateTime.Now.ToString())); if (needPause) { System.Threading.ThreadPool.QueueUserWorkItem(delegate { Trace.WriteLine("Sleep for 1 sec"); System.Threading.Thread.Sleep(1000); capture2.Start(); }); } }; capture2.ImageGrabbed += captureHandle; capture2.Start(); //int totalFrames = 69; Stopwatch s = Stopwatch.StartNew(); while (! (totalFrames1 == totalFrames2)) { System.Threading.Thread.Sleep(1000); if (s.ElapsedMilliseconds > 120 * 1000) { EmguAssert.IsTrue(false, "Unable to finished reading frames in 2 mins"); break; } } capture1.Dispose(); capture2.Dispose(); }