Exemple #1
0
        public void Send(SocketBuffer buffer, TcpSocketSendCallback callback)
        {
            TcpSocketSendRoutine routine = new TcpSocketSendRoutine(handle, buffer);
            TcpSocketSendResult  result  = new TcpSocketSendResult
            {
                Socket = this,
                Buffer = buffer,
                OnSent = callback
            };

            routine.Execute(result);
        }
Exemple #2
0
        public Task <TcpSocketSend> Send(SocketBuffer buffer)
        {
            TcpSocketSendResult result = new TcpSocketSendResult
            {
                Socket = this,
                Buffer = buffer,
                Event  = new ManualResetEvent(false)
            };

            Task <TcpSocketSend> task    = Task.Factory.FromAsync(result, ar => ((TcpSocketSendResult)ar).CreateData());
            TcpSocketSendRoutine routine = new TcpSocketSendRoutine(handle, buffer);

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