Ejemplo n.º 1
0
 public void Dispose()
 {
     if (_disposeRandom)
     {
         _cryptoRandom.Dispose();
     }
 }
Ejemplo n.º 2
0
        /// <summary>Instantly dispose all resources held by this host and connected peers.</summary>
        public void Dispose()
        {
            // State
            Disposed = true;

            // Receive worker
            try { ReceiveSemaphore.Dispose(); } catch { }
            try { ReceiveCancel.Cancel(); } catch { }
            try { ReceiveCancel.Dispose(); } catch { }
            // ReceiveWorker.Wait();

            // Peers
            try {
                PeersLock.EnterWriteLock();
                foreach (Peer peer in Peers.Values)
                {
                    peer.Dispose();
                }
                Peers.Clear();
            } catch { } finally {
                try { PeersLock.ExitWriteLock(); } catch { }
            }
            try { PeersLock.Dispose(); } catch { }

            // Socket
            try { Socket.Dispose(); } catch { }

            // Packet processing
            //try { Allocator.Dispose(); } catch { }
            try { Random.Dispose(); } catch { }
            try { Authenticator.Dispose(); } catch { }
            try { Compressor.Dispose(); } catch { }

            // Notify listener
            try { Listener.OnHostShutdown(); } catch { }
        }