public void Shutdown()
 {
     sendQueue.ShutdownGracefully();
     recvQueue.ShutdownGracefully();
     socket.Shutdown(SocketShutdown.Send);
     SenderTask.Wait();
     ReceiverTask.Wait();
 }
Esempio n. 2
0
        public void Disconnect()
        {
            CancellationSource.Cancel();

            if (SenderTask != null)
            {
                SenderTask.Wait();
                SenderTask = null;
            }

            if (ReceiverTask != null)
            {
                ReceiverTask.Wait();
                ReceiverTask = null;
            }

            if (Socket != null)
            {
                Socket.Close();
                Socket = null;
            }
        }