Forum Discussion

leandropoblet's avatar
leandropoblet
Frequent Contributor
11 years ago

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 corr...
  • simon_glet's avatar
    11 years ago
    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