110,538
社区成员
发帖
与我相关
我的任务
分享
time ti = new time("http://www.baidu.com");
Thread t = new Thread(new ThreadStart(ti.fill));
t.Start();
time ti1 = new time("http://www.google.com");
Thread t1 = new Thread(new ThreadStart(ti1.fill));
t1.Start();
time ti2 = new time("http://www.163.com");
Thread t2 = new Thread(new ThreadStart(ti2.fill));
t2.Start();
class time
{
private string url;
Process p = new Process();
private System.Timers.Timer t = new System.Timers.Timer(10000);
public time(string url)
{
this.url = url;
}
public void fill()
{
t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
t.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件;
}
public void theout(object source, System.Timers.ElapsedEventArgs e)
{
System.Timers.Timer _T = (System.Timers.Timer)source;
Random r = new Random();
_T.Interval = r.Next(100) * 1000;
ts.Browser.Start();
ts.Browser.Load(this.url, true);
p.StartInfo.FileName = "iexplore.exe";
p.StartInfo.Arguments = this.url;
p.Start();
}
}