ANW
14 years agoContributor
Sure way of stopping IE9 process every time??
Ok, so I am getting frustrated with IE process. I have some functions that try to close the process nicely, and 90% of the time that works, but sometimes it just refuses to close. So I included a terminate method if it wouldn't close properly. That doesn't seem to work much better.
So I am looking for some advice on how to be sure that the process closes every time I want it to.
The code I have look something like this:
procedure StartBrowser(browser, startURL: string);
var
Commandline : string;
begin
// If browser already exists, we close it down
browserProcess := Sys.WaitProcess(browser,100);
if browserProcess.exists then
StopBrowser;
// Setting up start page
Commandline := startURL;
...... snip .....
end;
procedure StopBrowser;
var
counter : integer;
begin
browserProcess.close;
counter := 0;
repeat
delay(200);
inc(counter);
until
(browserProcess.exists = false) OR (counter = 50);
if browserProcess.exists then begin
Log.error('Browser process could not be closed',
'Browser process did not close within timeout period. ');
browserProcess.terminate;
end
else
Log.message('Browser process closed',
'Browser process <' + VarToStr(browserProcess.Name) + '> was closed successfully');
Delay(1500);
end;
So basically what I do is that if the process is already running when I want to start the browser, I try to close it first. I send the close method to the process, and wait up to 10 seconds or until the process no longer exists. If it still exists after 10 seconds I send a terminate method.
Sadly, even with the terminate method, the Start script then complains that there is already a process running.
How can I make a function that will ensure that the IE browser process shuts down correctly every time??
I have not had these problems with FF3.6/FF4 browser at all.
So I am looking for some advice on how to be sure that the process closes every time I want it to.
The code I have look something like this:
procedure StartBrowser(browser, startURL: string);
var
Commandline : string;
begin
// If browser already exists, we close it down
browserProcess := Sys.WaitProcess(browser,100);
if browserProcess.exists then
StopBrowser;
// Setting up start page
Commandline := startURL;
...... snip .....
end;
procedure StopBrowser;
var
counter : integer;
begin
browserProcess.close;
counter := 0;
repeat
delay(200);
inc(counter);
until
(browserProcess.exists = false) OR (counter = 50);
if browserProcess.exists then begin
Log.error('Browser process could not be closed',
'Browser process did not close within timeout period. ');
browserProcess.terminate;
end
else
Log.message('Browser process closed',
'Browser process <' + VarToStr(browserProcess.Name) + '> was closed successfully');
Delay(1500);
end;
So basically what I do is that if the process is already running when I want to start the browser, I try to close it first. I send the close method to the process, and wait up to 10 seconds or until the process no longer exists. If it still exists after 10 seconds I send a terminate method.
Sadly, even with the terminate method, the Start script then complains that there is already a process running.
How can I make a function that will ensure that the IE browser process shuts down correctly every time??
I have not had these problems with FF3.6/FF4 browser at all.