AForge.Video.Kinect.Kinect.Dispose C# (CSharp) Method

Dispose() public method

Dispose device freeing all associated unmanaged resources.
public Dispose ( ) : void
return void
        public void Dispose( )
        {
            lock ( sync )
            {
                if ( rawDevice == IntPtr.Zero )
                    return;

                Dispose( true );
            }
            KinectNative.OnError -= new KinectNative.ErrorHandler( Kinect_OnError );
            GC.SuppressFinalize( this );
        }

Same methods

Kinect::Dispose ( bool disposing ) : void

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Stop video source.
        /// </summary>
        ///
        /// <remarks><para>The method stops the video source, so it no longer provides new video frames
        /// and does not consume any resources.</para>
        /// </remarks>
        ///
        public void Stop()
        {
            lock (sync)
            {
                lock (runningCameras)
                {
                    if (device != null)
                    {
                        var deviceFailed = Kinect.IsDeviceFailed(deviceID);

                        if (!deviceFailed)
                        {
                            KinectNative.freenect_stop_video(device.RawDevice);
                        }

                        device.Dispose();
                        device = null;
                        runningCameras.Remove(deviceID);

                        if (PlayingFinished != null)
                        {
                            PlayingFinished(this, (!deviceFailed) ?
                                            ReasonToFinishPlaying.StoppedByUser : ReasonToFinishPlaying.DeviceLost);
                        }
                    }

                    if (imageBuffer != IntPtr.Zero)
                    {
                        Marshal.FreeHGlobal(imageBuffer);
                        imageBuffer = IntPtr.Zero;
                    }

                    videoCallback = null;
                }
            }
        }
All Usage Examples Of AForge.Video.Kinect.Kinect::Dispose