Пример #1
0
        /// <summary>
        /// Releases the capture device
        /// </summary>
        private void Release()
        {
            if (m_thrdWorker != null)
            {
                // Yes, stop via the event
                m_rstevStopSignal.Set();

                Thread.Sleep(100);

                // Join the worker thread so we only continue when it exits.
                //_worker.Join();

                // Stop the thread.
                m_thrdWorker.Abort();

                // Dispose of the thread.
                m_thrdWorker = null;
            }

            // Clear the event
            if (m_rstevStopSignal != null)
            {
                m_rstevStopSignal.Close();
                m_rstevStopSignal = null;
            }

            // Clean up
            m_igrphbldGraph = null;
            m_sourceObject = null;
            m_grabberObject = null;
            m_isplGrabber = null;
            m_grbrCapGrabber = null;
            m_imedctrlControl = null;
        }
Пример #2
0
        /// <summary>;
        /// Starts grabbing images from the capture device
        /// </summary>
        public void Start()
        {
            // First check if we have a valid moniker string
            if (string.IsNullOrEmpty(m_sMonikerString)) return;

            // Check if we are already running
            if (this.IsRunning)
            {
                // Yes, stop it first
                this.Stop();
            }

            // Create new grabber
            m_grbrCapGrabber = new CCDGrabber();
            m_grbrCapGrabber.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(CCDGrabber_PropertyChanged);
            m_grbrCapGrabber.NewFrameArrived += new EventHandler(CCDGrabber_NewFrameArrived);

            // Create manual reset event
            m_rstevStopSignal = new ManualResetEvent(false);

            // Start the thread
            m_thrdWorker = new Thread(RunWorker);
            m_thrdWorker.Start();
        }