button_click事件:
Thread newthread = new Thread(new ThreadStart(did));
newthread.Start();
newthread.IsBackground = true;
if (record != "")
{
this.notifyIcon1.ShowBalloonTip(1, "温馨提示", "打开" + record+ "页面时出现异常,请联系13523859270", ToolTipIcon.Error); //气泡提示
record = "";
}
this.timer1.Interval = val * 60000; //val是用numbericupdown控件传递过来的值
this.timer1.Enabled = true;private void did()
{
Thread.Sleep(2000);
this.Invoke(new dg(list)); //dg是一个委托;
}
public void list()
{
rows = this.listView1.Items.Count;
int i = 0;
while (i < rows)
{
str = listView1.Items[i].SubItems[0].Text;
str2 = listView1.Items[i].SubItems[1].Text;
WebClient web = new WebClient();
byte[] data = web.DownloadData(str);
string res = Encoding.Default.GetString(data);
web.Dispose();
int loc1 = res.IndexOf("<title>");
int loc2 = res.IndexOf("</title>");
title = res.Substring(loc1 + 7, loc2 - (loc1 + 7)).ToString();
if (title !=str2)
{
// this.notifyIcon1.ShowBalloonTip(1, "温馨提示", "打开" + str2 + "页面时出现异常,请联系13523859270", ToolTipIcon.Error);
record += title.ToString() + ",";
}
i++;
}
}这段代码的意思是得到某网站的源代码 然后获得代码里<title></title>中间的值 与我设置的监控码(实际上也是网站的标题) 相比较 如果相等就不进行任何操作 如果不相等就气泡提示 并设有timer控件 让它每隔一段时间就检查一次 现在的问题是 当我单击按钮以后 线程应该开始了的 并检查错误 但我运行的结果是 等到我设置的那个时间段(timer.interval)之后 第一次检查才开始了 这是怎么回事 请高手帮帮我...小弟感激不尽~!..
Thread newthread = new Thread(new ThreadStart(did));
newthread.Start();
newthread.IsBackground = true;
if (record != "")
{
this.notifyIcon1.ShowBalloonTip(1, "温馨提示", "打开" + record+ "页面时出现异常,请联系13523859270", ToolTipIcon.Error); //气泡提示
record = "";
}
this.timer1.Interval = val * 60000; //val是用numbericupdown控件传递过来的值
this.timer1.Enabled = true;private void did()
{
Thread.Sleep(2000);
this.Invoke(new dg(list)); //dg是一个委托;
}
public void list()
{
rows = this.listView1.Items.Count;
int i = 0;
while (i < rows)
{
str = listView1.Items[i].SubItems[0].Text;
str2 = listView1.Items[i].SubItems[1].Text;
WebClient web = new WebClient();
byte[] data = web.DownloadData(str);
string res = Encoding.Default.GetString(data);
web.Dispose();
int loc1 = res.IndexOf("<title>");
int loc2 = res.IndexOf("</title>");
title = res.Substring(loc1 + 7, loc2 - (loc1 + 7)).ToString();
if (title !=str2)
{
// this.notifyIcon1.ShowBalloonTip(1, "温馨提示", "打开" + str2 + "页面时出现异常,请联系13523859270", ToolTipIcon.Error);
record += title.ToString() + ",";
}
i++;
}
}这段代码的意思是得到某网站的源代码 然后获得代码里<title></title>中间的值 与我设置的监控码(实际上也是网站的标题) 相比较 如果相等就不进行任何操作 如果不相等就气泡提示 并设有timer控件 让它每隔一段时间就检查一次 现在的问题是 当我单击按钮以后 线程应该开始了的 并检查错误 但我运行的结果是 等到我设置的那个时间段(timer.interval)之后 第一次检查才开始了 这是怎么回事 请高手帮帮我...小弟感激不尽~!..
private void did()
{
//Thread.Sleep(2000);
this.Invoke(new dg(list)); //dg是一个委托;
}