HoloToolkit.Sharing.DiscoveryClient.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
  public virtual void Dispose() {
    lock(this) {
      if (swigCPtr.Handle != global::System.IntPtr.Zero) {
        if (swigCMemOwn) {
          swigCMemOwn = false;
          SharingClientPINVOKE.delete_DiscoveryClient(swigCPtr);
        }
        swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
      }
      global::System.GC.SuppressFinalize(this);
    }
  }

Usage Example

Ejemplo n.º 1
0
        protected void OnDestroy()
        {
            Instance = null;

            if (this.discoveryClient != null)
            {
                discoveryClient.RemoveListener(discoveryClientAdapter);
                discoveryClient.Dispose();
                discoveryClient = null;

                if (discoveryClientAdapter != null)
                {
                    discoveryClientAdapter.Dispose();
                    discoveryClientAdapter = null;
                }
            }

            if (this.sharingMgr != null)
            {
                // Force a disconnection so that we can stop and start Unity without connections hanging around
                this.sharingMgr.GetPairedConnection().Disconnect();
                this.sharingMgr.GetServerConnection().Disconnect();

                // Release the XTools manager so that it cleans up the C++ copy
                this.sharingMgr.Dispose();
                this.sharingMgr = null;
            }
            // Forces a garbage collection to try to clean up any additional reference to SWIG-wrapped objects
            System.GC.Collect();
        }
All Usage Examples Of HoloToolkit.Sharing.DiscoveryClient::Dispose