public static bool WaitForCondition( IWaitClient client, int timeout, int interval, out int elapsed) { elapsed=0; client.WaitCallback(WaitState.begin_state,0); StopWatch watch = new StopWatch(); watch.Start(); bool success=false; while ( watch.ElapsedMiliseconds <= timeout) { if ( client.StopWaiting() == true ) { client.WaitCallback(WaitState.finished_state , watch.ElapsedMiliseconds ); success=true; break; } System.Threading.Thread.Sleep( interval); client.WaitCallback(WaitState.interval_state , watch.ElapsedMiliseconds ); } client.WaitCallback(WaitState.timeout_state ,watch.ElapsedMiliseconds ); return success; }
public static bool WaitForCondition(IWaitClient client, int timeout, int interval, out int elapsed) { elapsed = 0; client.WaitCallback(WaitState.begin_state, 0); StopWatch watch = new StopWatch(); watch.Start(); bool success = false; while (watch.ElapsedMiliseconds <= timeout) { if (client.StopWaiting() == true) { client.WaitCallback(WaitState.finished_state, watch.ElapsedMiliseconds); success = true; break; } System.Threading.Thread.Sleep(interval); client.WaitCallback(WaitState.interval_state, watch.ElapsedMiliseconds); } client.WaitCallback(WaitState.timeout_state, watch.ElapsedMiliseconds); return(success); }
public static void Window_SetAsForegroundWindow(int hwnd) { WindowsAutomation.win32.SetForegroundWindow(hwnd); int timeout = 3 * 1000; bool err = true; Timing.StopWatch w1 = new Timing.StopWatch(); w1.Start(); while (w1.ElapsedMiliseconds < timeout) { if (WindowsAutomation.win32.GetForegroundWindow() == hwnd) { err = false; break; } System.Threading.Thread.Sleep(250); } if (err) { throw new Errors.AutomationError("Did not set FG window"); } }
public static void Window_SetAsForegroundWindow( int hwnd ) { WindowsAutomation.win32.SetForegroundWindow(hwnd); int timeout = 3 * 1000; bool err=true; Timing.StopWatch w1 = new Timing.StopWatch(); w1.Start(); while (w1.ElapsedMiliseconds < timeout ) { if ( WindowsAutomation.win32.GetForegroundWindow() == hwnd ) { err=false; break; } System.Threading.Thread.Sleep(250); } if (err) { throw new Errors.AutomationError( "Did not set FG window"); } }