public static IAsyncResult BeginConnect(IPEndPoint debugEndPoint, StreamReader console, AsyncCallback callback, TextWriter logWriter = null) { Socket debugSocket = null; debugSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); ConnectWithConsoleOutputCallback c = new ConnectWithConsoleOutputCallback(ConnectWithConsoleOutput); return(c.BeginInvoke(debugSocket, debugEndPoint, console, logWriter, callback, debugSocket)); }
public static VirtualMachine EndConnect(IAsyncResult asyncResult) { if (asyncResult == null) { throw new ArgumentNullException("asyncResult"); } if (!asyncResult.IsCompleted) { asyncResult.AsyncWaitHandle.WaitOne(); } AsyncResult result = (AsyncResult)asyncResult; ConnectWithConsoleOutputCallback cb = (ConnectWithConsoleOutputCallback)result.AsyncDelegate; return(cb.EndInvoke(asyncResult)); }