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); }
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); }