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); }