public void sendRoomData(ConnectedUser User) { WaitDelegate X = new WaitDelegate(sendRoomData2); IAsyncResult ar = X.BeginInvoke(User, null, null); ar.AsyncWaitHandle.WaitOne(1000, false); if (ar.IsCompleted) { X.EndInvoke(ar); } }
private void _2() { //Cyclic polling WaitDelegate wd = Wait; IAsyncResult ar = wd.BeginInvoke(2000, null, null); //Running while (!ar.IsCompleted) { Console.WriteLine("!ar.IsCompleted"); Thread.Sleep(100); } //Get result int res = wd.EndInvoke(ar); Console.WriteLine(res); //If the main process is terminated, so subprocess is terminate too }