Esempio n. 1
0
        public void Receive(SocketBuffer buffer, TcpSocketReceiveCallback callback)
        {
            TcpSocketReceiveRoutine routine = new TcpSocketReceiveRoutine(handle, buffer);
            TcpSocketReceiveResult  result  = new TcpSocketReceiveResult
            {
                Socket     = this,
                Buffer     = buffer,
                OnReceived = callback
            };

            routine.Execute(result);
        }
Esempio n. 2
0
        public Task <TcpSocketReceive> Receive(SocketBuffer buffer)
        {
            TcpSocketReceiveResult result = new TcpSocketReceiveResult
            {
                Socket = this,
                Buffer = buffer,
                Event  = new ManualResetEvent(false)
            };

            Task <TcpSocketReceive> task    = Task.Factory.FromAsync(result, ar => ((TcpSocketReceiveResult)ar).CreateData());
            TcpSocketReceiveRoutine routine = new TcpSocketReceiveRoutine(handle, buffer);

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