I have written a simple program to access a web page and have it refresh every minute. To get to refresh automatically,I have inserted a timer. I have also included a thread to write a message in a text box whenever the page is refreshed. I got much of the code verbatim from the MSDN docs. However, I can't get it to work.
Below is the code. If anybody has any ideas, I'm all ears. If somebody can give me some tips on debugging a Timer that would be greatly appreciated as well.
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//DialogResult result;
string theUrl = "http://10.170.8.133:8080/OvisDashboard/jsp/StatusWorkspaceView.jsp";
if (webBrowser1.Url.ToString() != theUrl)
{
this.webBrowser1.Navigate(new Uri(theUrl));
}
initTimer();
}
private void startTextThread()
{
this.SetText("Web page refreshed.");
}
private void SetText(string text)
{
if (this.textBox1.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.textBox1.Text = text;
}
}
private void initTimer()
{
tmr=new System.Timers.Timer(60000);
tmr.Elapsed+=new ElapsedEventHandler(tmr_Elapsed);
tmr.AutoReset=true;
tmr.Enabled = true;
}
private void tmr_Elapsed(object source, ElapsedEventArgs e)
{
string refreshMsg = "Web page refreshed.";
textBox1.Text = refreshMsg;
this.myThread = new Thread(new ThreadStart(this.startTextThread));