/// <summary> /// Releases the capture device /// </summary> private void Release() { // Stop the thread _worker = null; // Clear the event if (_stopSignal != null) { _stopSignal.Set(); //_Signal.Close(); _stopSignal = null; } // Clean up //_graph = null; //_sourceObject = null; //_grabberObject = null; //_grabber = null; _capGrabber = null; //_control = null; }
/// <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 += capGrabber_PropertyChanged; _capGrabber.NewFrameArrived += capGrabber_NewFrameArrived; // Create manual reset event _stopSignal = new AutoResetEvent(false); // Start the thread _worker = new Thread(RunWorker); _worker.Start(); }