Exemplo n.º 1
0
        /// <summary>
        /// Ends acquisition and de-configures the session
        /// </summary>
        public void Stop()
        {
            if (!_captureRunning)
            {
                System.Diagnostics.Debug.WriteLine("Tried to stop non-running capture");
                return;
            }
            uint lastBuffNum;

            NIImaq.imgSessionAbort(_sid, out lastBuffNum);

            System.Threading.Thread.Sleep(500);
            if (_bufId != 0)
            {
                NIImaq.imgMemUnlock(_bufId);
            }
            //free buffers
            for (int i = 0; i < (uint)_ringBuffer.Length; i++)
            {
                if (_ringBuffer[i] != IntPtr.Zero)
                {
                    NIImaq.imgDisposeBuffer(_ringBuffer[i]);
                }
            }
            //close buffer list
            if (_bufId != 0)
            {
                NIImaq.imgDisposeBufList(_bufId, false);
            }
            _captureRunning = false;
            _configured     = false;
        }