AForge.Video.Ximea.XimeaCamera.Close C# (CSharp) Method

Close() public method

Close opened camera (if any) and release allocated resources.

The method also calls StopAcquisition method if it was not done by user.

An error occurred while communicating with a camera. See error /// message for additional information.
public Close ( ) : void
return void
        public void Close( )
        {
            lock ( sync )
            {
                if ( deviceHandle != IntPtr.Zero )
                {
                    if ( isAcquisitionStarted )
                    {
                        try
                        {
                            StopAcquisition( );
                        }
                        catch
                        {
                        }
                    }

                    try
                    {
                        int errorCode = XimeaAPI.xiCloseDevice( deviceHandle );
                        HandleError( errorCode );
                    }
                    finally
                    {
                        deviceHandle = IntPtr.Zero;
                    }
                }
            }
        }

Usage Example

コード例 #1
0
        // Free resources
        private void Free()
        {
            lock (sync)
            {
                thread = null;

                // release events
                if (stopEvent != null)
                {
                    stopEvent.Close();
                    stopEvent = null;
                }

                camera.Close();
            }
        }