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

Microtigers Microtigers 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

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个线程..每个线程都是每个一个随机时间打开一个网址.
不知道哪里错误....高手指点一下...应该怎么修改
...全文
评论 1
收藏 已收藏
分享
返回顶部
Microtigers
C# 111,130 成员 642,541 内容