前线程不在单线程单元中,因此无法实例化 ActiveX 控件“8856f961-340a-11d0-a96b-00c04fd705a2”。


在vs.net2008中多线程处理webbroswer遇到了错误。如题目所示。

在网上找到了办法。

例程:

string url = this.listBox1.SelectedItem.ToString(); 
if (url.StartsWith("Url :")) 
{ 
url = url.Remove(0, 5); 
MessageBox.Show(url); 
System.Threading.ThreadStart start = new System.Threading.ThreadStart(download); 
System.Threading.Thread th = new System.Threading.Thread(start); 
th.ApartmentState = System.Threading.ApartmentState.STA;//这句关键的 
th.Start(); 
}

MSDN解释:http://msdn.microsoft.com/en-us/library/system.threading.apartmentstate.aspx


发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

验证码 * Time limit is exhausted. Please reload CAPTCHA.