コード例 #1
0
 internal static void ThrowIfNotOK(NatNetError result, string message)
 {
     if (result != NatNetError.NatNetError_OK)
     {
         throw new NatNetException(message + " (" + result.ToString() + ")");
     }
 }
コード例 #2
0
        /// <summary>
        /// Called by both the <see cref="IDisposable.Dispose()"/> override,
        /// as well as the finalizer, to do the actual cleanup work.
        /// </summary>
        /// <param name="disposing">
        /// True if <see cref="Dispose()"/> was called explicitly. False if
        /// running as part of the finalizer. If false, do not attempt to
        /// reference other managed objects, since they may have already been
        /// finalized themselves.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (m_disposed)
            {
                return;
            }

            // Disconnect if necessary.
            if (Connected)
            {
                NatNetError disconnectResult = NatNetLib.NativeMethods.NatNet_Client_Disconnect(m_clientHandle);

                if (disconnectResult != NatNetError.NatNetError_OK)
                {
                    System.Diagnostics.Debug.WriteLine("NatNet_Client_Disconnect returned " + disconnectResult.ToString() + ".");
                }

                Connected = false;
            }

            // Now destroy the native client.
            NatNetError destroyResult = NatNetLib.NativeMethods.NatNet_Client_Destroy(m_clientHandle);

            if (destroyResult != NatNetError.NatNetError_OK)
            {
                System.Diagnostics.Debug.WriteLine("NatNet_Client_Destroy returned " + destroyResult.ToString() + ".");
            }

            m_clientHandle = IntPtr.Zero;

            m_disposed = true;
        }
コード例 #3
0
ファイル: Client.cs プロジェクト: chobitsfan/MultiDrone
        /// <summary>
        /// Called by both the <see cref="IDisposable.Dispose()"/> override,
        /// as well as the finalizer, to do the actual cleanup work.
        /// </summary>
        /// <param name="disposing">
        /// True if <see cref="Dispose()"/> was called explicitly. False if
        /// running as part of the finalizer. If false, do not attempt to
        /// reference other managed objects, since they may have already been
        /// finalized themselves.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (m_disposed)
            {
                return;
            }

            // Now destroy the native discovery handle.
            NatNetError destroyResult = NatNetLib.NativeMethods.NatNet_FreeAsyncServerDiscovery(m_discoveryHandle);

            if (destroyResult != NatNetError.NatNetError_OK)
            {
                System.Diagnostics.Debug.WriteLine("NatNet_FreeAsyncServerDiscovery returned " + destroyResult.ToString() + ".");
            }

            m_discoveryHandle = IntPtr.Zero;

            m_disposed = true;
        }