Is it possible to wait for a runapplication to complete

Ask general questions here.
garyb576
Posts: 7
Joined: Fri Nov 05, 2010 12:43 pm

Is it possible to wait for a runapplication to complete

Post by garyb576 » Mon May 20, 2013 1:59 pm

I am trying to run a shell command within my test using runapplication. however, I also want to wait for that to complete before my scripts continue and carry on. Is there a way of doing this?
I can manually add a delay after using runapplication, however, I wanted the test to bit smarter than that and to wait til it completes.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7469
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Is it possible to wait for a runapplication to complete

Post by odklizec » Mon May 20, 2013 3:02 pm

Hi,

Try for example Wait For Not Exists action. Set a reasonable timer based of your experience with the execution time of your shell script. If you set the timer too low, the next action will be started before the shell script is finished! Just "Wait" action right after the action where you start the shell command...
WaitForNotExists_1.png
Eventually, you can do something similar from code, using the process name and while loop with timeout...
WaitForNotExists_2.png
using System.Diagnostics;
        public void Wait_For_Not_Exist_code()
        {
        	int ElapsedTime = 0;
        	while (Process.GetProcessesByName("cmd").Length >= 1 && ElapsedTime < 300000)
        	{
        		Thread.Sleep(1000);
        		ElapsedTime += 1000;
        	}
        }
Hope this helps?
You do not have the required permissions to view the files attached to this post.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

garyb576
Posts: 7
Joined: Fri Nov 05, 2010 12:43 pm

Re: Is it possible to wait for a runapplication to complete

Post by garyb576 » Tue May 21, 2013 7:59 am

I have decided to use system.diagnostics and use the new process and within that use process.waitforexit etc
This seems to be working as expected.
Thanks for your suggestion.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7469
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Is it possible to wait for a runapplication to complete

Post by odklizec » Tue May 21, 2013 9:11 am

You are welcome. And thanks for sharing your solution!
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration