Example #1
0
        public override void Shutdown()
        {
            // stop accepting new messages
            ShutdownWorker();
            Thread.Sleep(100);

            if (WorkerThread != null)
            {
                WorkerThread.Abort();
            }

            WorkerThread = null;

            lock (ConnectedPeers)
            {
                foreach (var p in ConnectedPeers)
                {
                    p.Value.SocketConnection.Disconnect("shutdown");
                    p.Value.SocketConnection.Peer.FlushSendQueue();
                    p.Value.Handler.PeerDisconnected("Force Shutdown", p.Value);
                }
                ConnectedPeers.Clear();
            }
            base.Shutdown();
        }