Beispiel #1
0
		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;
		}
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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");
            }
        }
Beispiel #4
0
		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");
			}
		}