多线程同时调用错误,应用程序调用一个已为另一线程整理的接口

Microtigers 2009-09-04 04:41:49

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();

}
}

出现错误:
Can not get scroll size: System.Runtime.InteropServices.COMException

(0x800706BF): 远程过程调用失败且未运行。 (异常来自 HRESULT:0x800706BF)
在 mshtml.HTMLDocumentClass.IHTMLDocument2_get_body()
在 Shrinerain.AutoTester.Core.TestInternetExplorer.GetScrollRect()
应用程序调用一个已为另一线程整理的接口
我的目的:
我想启动3个线程..每个线程都是每个一个随机时间打开一个网址.
不知道哪里错误....高手指点一下...应该怎么修改
...全文
602 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
limeng315 2009-09-04
  • 打赏
  • 举报
回复
你的Process P不能定义为公共的,一个P同时只能执行一个进程,也就是一个iexplore.exe,把Process的定义放到方法theout中试试吧。

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧