예제 #1
0
        public void Disconnect(TcpSocketDisconnectCallback callback)
        {
            TcpSocketDisconnectRoutine routine = new TcpSocketDisconnectRoutine(handle);
            TcpSocketDisconnectResult  result  = new TcpSocketDisconnectResult
            {
                Handle         = handle,
                Socket         = this,
                OnDisconnected = callback
            };

            routine.Execute(result);
        }
예제 #2
0
        public Task <TcpSocketDisconnect> Disconnect()
        {
            TcpSocketDisconnectResult result = new TcpSocketDisconnectResult
            {
                Handle = handle,
                Socket = this,
                Event  = new ManualResetEvent(false)
            };

            Task <TcpSocketDisconnect> task    = Task.Factory.FromAsync(result, ar => ((TcpSocketDisconnectResult)ar).CreateData());
            TcpSocketDisconnectRoutine routine = new TcpSocketDisconnectRoutine(handle);

            routine.Execute(result);
            return(task);
        }