MyApp.exe中0x0e90a1c0处的未处理异常:0xC0000005:访问冲突。
基于帖子How might I create and use a WebBrowser control on a worker thread?我试图在另一个帖子上运行WebPagePump
类。
for (int i = 0; i < 5; i++)
{
Thread t = new Thread(delegate() { WebNav1(); });
t.Start();
}
private Action WebNav1 = delegate()
{
WebPagePump a = new WebPagePump();
a.Navigate(new Uri("http://www.mywebsite.com"));
a.Completed += delegate(WebBrowser wb)
{
Console.WriteLine("It's loaded!");
a.Dispose();
};
};
答案 0 :(得分:2)
您需要指定单线程公寓:
Thread t = new Thread(delegate() { WebNav1(); });
t.ApartmentState = ApartmentState.STA;
t.Start();