/// <summary>; /// Starts grabbing images from the capture device /// </summary> public void Start() { // First check if we have a valid moniker string if (string.IsNullOrEmpty(_monikerString)) { return; } // Check if we are already running if (IsRunning) { // Yes, stop it first Stop(); } // Create new grabber _capGrabber = new CapGrabber(); _capGrabber.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(capGrabber_PropertyChanged); _capGrabber.NewFrameArrived += new EventHandler(capGrabber_NewFrameArrived); // Create manual reset event _stopSignal = new ManualResetEvent(false); // Start the thread _worker = new Thread(RunWorker); _worker.Start(); }
/// <summary> /// Releases the capture device /// </summary> private void Release() { // Stop the thread _worker = null; // Clear the event if (_stopSignal != null) { _stopSignal.Close(); _stopSignal = null; } // Clean up _graph = null; _sourceObject = null; _grabberObject = null; _grabber = null; _capGrabber = null; _control = null; }