Waiting for a web page to load on shutdown

G

Guest

I'm new to c# and am currently developing a small login/logout app that runs
in the system tray. I am trying to get it to access a website during system
shutdown, but it doesn't seem to want to.


//catch message from windows on shutdown
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x11)
{
this.flagBoolean1 = true; //set flag for closing app OK

string currentUrl = webBrowser1.Url;

if (currentUrl.Contains("webpage1"))
webBrowser1.Navigate("webpage2");

else Shutdown();
}
base.WndProc(ref m);
}

//the close form cancel function for system tray app
private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
//really close app?
if (!flagBoolean1)
{
e.Cancel = true;
this.Visible = false;
}
else
{
string currentUrl = webBrowser1.Url;

//tried the web navigation at both locations to no avail
if (currentUrl.Contains("webpage1"))
{
webBrowser1.Navigate("webpage2");
}
Shutdown();
}
}


private void Shutdown()
{
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
this.notifyIcon1.Visible = false;
this.Dispose();
Application.Exit();
this.Close();
}
 
G

Guest

Sorry, i didn't get a chance to finish my post and somehow posted it anyway.
I am looking for ideas on how to get it to access the website "webpage2" when
shutdown is called, then to procceed with shutdown once the page is fully
loaded.
 

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