问题描述
这是入口publicvoidrun(){WebBrowserwebBrowser1=newWebBrowser();webBrowser1.Name=Thread.CurrentThread.ManagedThreadId.ToString();webBrowser1.DocumentCompleted+=newWebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);s=generate(5);Randomr=newRandom();intia=r.Next(0,5);stringaddress=straddress[ia];//if(address!=String.Empty)//{//RefreshIESettings(address);//}try{while(ii<1){webBrowser1.Navigate("http://www.baidu.com",null,null,null);//Thread.Sleep(10000);//System.Console.WriteLine(ii.ToString()+s+webBrowser1.Name+address+webBrowser1.Url.ToString());Thread.Sleep(15000);ii+=1;}}catch(Exceptionex){System.Console.WriteLine("run:"+ex.Message);}这是winform中的代码privatevoidbutton4_Click(objectsender,EventArgse){for(inti=0;i<10;i++){Class1gooo=newClass1();System.Threading.Threads=newSystem.Threading.Thread(newSystem.Threading.ThreadStart(gooo.run));s.SetApartmentState(System.Threading.ApartmentState.STA);s.Start();}}
解决方案
解决方案二:
如果不放人子线程,代码是可以运行的,对线程很迷茫,请指点
解决方案三:
问题没有表述清楚?请指点
解决方案四:
该回复于2011-11-04 17:39:45被版主删除
解决方案五:
WebBrowserwebBrowser1=newWebBrowser();webBrowser1.Name=Thread.CurrentThread.ManagedThreadId.ToString();webBrowser1.DocumentCompleted+=newWebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);放在button4_Click里