在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