Forum Discussion

NisHera's avatar
NisHera
Valued Contributor
10 years ago
Solved

Waiting for application shut down

My application auto should down in certain operations (which is normal) while shutting down it had to process many background jobs. So I need to wait till it’s down to restart and go on. So I wrote following.

 

for(j=0;j<101;j++){
     Sys.WaitProcess("Application").Exists? Delay(4000,'.............Waiting for close down'):j=100;
  }

 

It gives me error Application.exe process crashed, it is not crash but intentional shut down.

any idea on handling it better way?

 

  • Hi Nishera,

     

    You forgot to specify the Timeout parameter in the WaitProcess method:

    Sys.WaitProcess("Application",2000).Exists...
  • m_essaid's avatar
    m_essaid
    Valued Contributor

    Hi,

     

    A little procedure to wait for a process to close before a duration.

    If the process closes, the loop stops.

     

    function WaitProcessus(NameProcessus: string; time: integer): boolean;
    var
      p, IsOpen;
      i: integer;

    begin
      result:= false;
      i:= 0;
      p := Sys.FindChild('ProcessName', NameProcessus);
      while not p.Exists do
      begin
        i:= i + 2000;
        Delay(2000);
        if (i >= time) then
        begin
          result:= false;
          exit;
        end;
      end;
      result:= true;
    exit;
    end;

  • Hi Nishera,

     

    You forgot to specify the Timeout parameter in the WaitProcess method:

    Sys.WaitProcess("Application",2000).Exists...