コード例 #1
0
        private Device(NativeMethods.k4a_device_t handle)
        {
            // Hook the native allocator and register this object.
            // .Dispose() will be called on this object when the allocator is shut down.
            Allocator.Singleton.RegisterForDisposal(this);

            this.handle = handle;
        }
コード例 #2
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>True</c> to release both managed and unmanaged resources; <c>False</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposedValue)
            {
                if (disposing)
                {
                    Allocator.Singleton.UnregisterForDisposal(this);

                    this.handle.Close();
                    this.handle = null;

                    this.disposedValue = true;
                }
            }
        }
コード例 #3
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.
                handle.Close();
                handle = null;

                disposedValue = true;
            }
        }
コード例 #4
0
 /// <summary>
 /// Opens an Azure Kinect device.
 /// </summary>
 /// <param name="index">Index of the device to open if there are multiple connected.</param>
 /// <returns>A Device object representing that device.</returns>
 /// <remarks>The device will remain opened for exclusive access until the Device object is disposed.</remarks>
 public static Device Open(int index = 0)
 {
     NativeMethods.k4a_device_t handle = default;
     AzureKinectOpenDeviceException.ThrowIfNotSuccess(() => NativeMethods.k4a_device_open((uint)index, out handle));
     return(new Device(handle));
 }
コード例 #5
0
 private Device(NativeMethods.k4a_device_t handle)
 {
     this.handle = handle;
 }