Forum Discussion

mgroen2's avatar
mgroen2
Super Contributor
9 years ago
Solved

How to check (and close) processes in a loop?

In my keyword tests, I need to check on some active processing before starting execution. However, if these processes are active, I need to close them.  I do not know how many instances of these pr...
  • dmiscannon's avatar
    dmiscannon
    9 years ago

    The following works for me using Excel as an example with Keyword tests. In the If Object dialog box, I just typed in the process (Sys.Process("Excel")) I wanted to check. I used a Go Label to make the process 'loop'.

     

    CloseProcess.jpeg

     

     

  • AlexKaras's avatar
    9 years ago

    Hi,

     

    > some active processing 

    If those processes were started as Tested Applications by TestComplete, then CloseAll method (https://support.smartbear.com/viewarticle/68083/) might help.

     

    Otherwise, the pseudocode is like this:

    repeat

      search for any instance of the process (i.e. ignoring its index)

      if the process is found

        call Close method for it

        loop until the process exists and timeout was not exceeded

          wait a bit ( .Delay(500) )

          if timeout expired

            call Terminate for the process

        end of loop

      end of if

    until the process is found