private Task ConnectAsyncCore(string host, int port) { return Task.Factory.FromAsync( (targetHost, targetPort, callback, state) => ((TcpClient)state).BeginConnect(targetHost, targetPort, callback, state), asyncResult => ((TcpClient)asyncResult.AsyncState).EndConnect(asyncResult), host, port, state: this); }