private void _4() { //Probably equivalent like _2() WaitDelegate wd = Wait; IAsyncResult ar = wd.BeginInvoke(3000, null, null); while (ar.AsyncWaitHandle.WaitOne(50, true)) /* waiting */ } {
/// <summary> /// Initializes a new instance of the DynamicEval class. /// </summary> /// <param name="highlightDelegate">An implementation of the 'Highlight' function.</param> /// <param name="highlightBoxDelegate">An implementation of the 'HighlightBox' function.</param> /// <param name="waitDelegate">An implementation of the 'Wait' function.</param> public DynamicEval(HighlightDelegate highlightDelegate, HighlightBoxDelegate highlightBoxDelegate, WaitDelegate waitDelegate) { this.highlightDelegate = highlightDelegate; this.highlightBoxDelegate = highlightBoxDelegate; this.waitDelegate = waitDelegate; this.Initialize(); }
//Global variable for example _3 - not necessery (see third parameter BeginInvoke in _3) //private WaitDelegate wd; private void _3() { WaitDelegate wd = Wait; //Equivalent, but parameters are seen //AsyncCallback ac = new AsyncCallback(WaitCallback) //Is properly passing delegate instance like third (object) parameter IAsyncResult ar = wd.BeginInvoke(1000, WaitCallback, wd); }
public WaitWindow(Window owner, string title, WaitDelegate waitAction, object threadParameter) { InitializeComponent(); Title = title; WaitInfoTextBlock.Text = title; WaitAction = waitAction; Owner = owner; ThreadParameter = threadParameter; }
/// <summary> /// Waits for millis milliseconds /// </summary> /// <param name="millis"></param> public void wait(int millis) { Wait wait = new Wait(); WaitDelegate wDel = new WaitDelegate(wait.waitFor); System.Console.WriteLine("CALLING WAIT " + millis); isSleep = true; wDel.BeginInvoke(millis, new AsyncCallback(CallBackMethod), wDel); }
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); } }
public void WaitForCondition(WaitDelegate waitDelegate, int msecTimeout = 500) { WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromMilliseconds(msecTimeout)); wait.Until( (d) => { try { return(waitDelegate(d)); } catch { return(false); } }); }
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 }
public NamedPipeCommunication(string str)//コンストラクタ { name = str; waitDelegate = WaitConnectionOnDelegate; readDelegate = ReadOnDelegate; connectState = ConnectState.notBornYet; ConnectStateLabel = "パイプ作成"; MessageLabel = ""; try { connectState = ConnectState.born; pipeS = new NamedPipeServerStream(str, PipeDirection.In, 1, PipeTransmissionMode.Byte); } catch (Exception e) { ConnectStateLabel = "パイプ作成に失敗"; MessageBox.Show(e.ToString()); connectState = ConnectState.dead; } }
private void wait(bool exit) { if (this.InvokeRequired) { WaitDelegate w = new WaitDelegate(wait); this.Invoke(w, exit); } else { if (exit) { //游戏结束,退出 MessageBox.Show("演练流程结束", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClientDAL.GetInstance().stopThread(); this.DialogResult = DialogResult.OK; } else { //游戏未结束,等待 this.panel1.Controls.Add(lblWait); } } }
public WaitWindow(Window owner, string title, WaitDelegate waitAction) : this(owner, title, waitAction, null) { }