leandropoblet
11 years agoFrequent Contributor
Waiting for process to terminate fails
I'm trying to make this function work, but unfortunately I couldn't so far:
while (stillRunning)
{
if (timeOut > maxTime)
{
Log["Error"]("The App failed to shutdown correctly.");
break;
}
else
{
if (Aliases[process]["Exists"])
{
timeOut+=1000;
if ((timeOut % 1000) == 0)
{
Log["Message"]("The Application process is still running. " + (timeOut / 1000) + " seconds and waiting");
}
}
else
{
stillRunning = false;
}
}
}
Log["Message"]("The Application process has been shutdown correctly.");
}
It seems pretty obvious what it does. It would wait a maxTime checking if the application (WPF) is closed.
Now, the thing is TestComplete 9 won't recognize when the application's been closed. I mean... I can clearly see how the process is not there anymore in Task Manager whereas TC keeps counting until it reaches the limit time (more than enough in this case).
Any clues? Cheers
- Hi Leandro,
The code you provided executes immediately with no waiting at all.
Try something like this:
function TestNotepadCloseWithAlias()
{
var maxDelay = 10000;
var interval = 2000;
var stopWatch = HISUtils.StopWatch;
stopWatch.Start();
while(Aliases.notepad.Exists){
Delay(interval);
if(stopWatch.Split() > maxDelay){
break;
} else {
Log.Message("Waiting for " + stopWatch.ToString() + " Will wait for application to close");
}
}
stopWatch.Stop();
if(Aliases.notepad.Exists)
{
Log.Error("Application did not close in time " + maxDelay + " milliseconds");
} else {
Log.Message("Application closed in " + stopWatch.ToString());
}
}
Sincerely