How do you wait for an IE process to finish when started with Process.Start()

  • Thread starter Stephen Haeney via .NET 247
  • Start date
S

Stephen Haeney via .NET 247

I am developing a WinForm application which will redirect theuser to HTML page, using IE, when they click a button. However,I want this to be modal in operation, so I would like to makesure that the IE process has finished before I allow then tocontinue.

I first tried using the WaitForExit method of the Process class,but this returns an error while IE is still showing the HTMLpage. Is there any way that I can ensure the page is closedbefore allowing the user to continue?

If possible, I would like to stay away from using an embeddedbrowser control as this looks a little bit too complex for whatI am trying to achieve.

A code sample is below

ProcessStartInfo startupInfo = new ProcessStartInfo ();
startupInfo.FileName = filePath;
startupInfo.UseShellExecute = true;
startupInfo.CreateNoWindow = true;
Process process = Process.Start (startupInfo);
process.WaitForExit();

The filePath variable is the fully qualified path to a HTMLdocument. By the time the WaitForExit is called, an Objectreference not set exception is thrown.

Thanks in advance
 
C

Cor Ligthert

Hi Stephen,

I think that this will be a hard way to go, the user can open another window
in IE or a page can do that for him.

Why not building your own webbrowser with limited browser capabilities.

It is almost here already completly for you.

webbrowser
http://support.microsoft.com/?kbid=311303

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top