public void Shutdown()
 {
     sendQueue.ShutdownGracefully();
     recvQueue.ShutdownGracefully();
     socket.Shutdown(SocketShutdown.Send);
     SenderTask.Wait();
     ReceiverTask.Wait();
 }
示例#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;
            }
        }
        public void Disconnect()
        {
            CancellationSource.Cancel();

            if (SenderTask != null)
            {
                //  Remove this line and se if that fix the problem.
                // SenderTask.Wait();
                SenderTask = null;
            }

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

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