WebBrowser and Invoke in BackGroundWorker Crash

-1

i did a question about my app crash without reason and i recive only with exit code -2146233082 (0x80131506) nothing More(saw today). So i asked on StackOverflow and someone told me that the fault was the code inside the BackGroundWorker

no way that Start.Back.PerformClick() could work. And none of the BGW code actually runs on the worker thread.

. So i change it but i would know if it's ok or not becouse it still crash without any exception and anything(i saw in Windows Event log and i catch unhandled Exception) i recive only that code -2146233082 (0x80131506) and nothing more , neither Form Close or Closing Event was fired, it stop. .

I use as Browser "GeckoFX"

Here The OLD code

   private void Start_Back_Click(object sender, EventArgs e)
    {                         
        List<Links> tempList = getListFromWeb();

        if (!backgroundWorker1.IsBusy)
        { 
            backgroundWorker1.RunWorkerAsync(tempGoogle);
        } 
    }

 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        { 
            List<Links> temp = (List<Links>)e.Argument; 
            foreach (Links link in temp)
            {                 
                if (backgroundWorker1.CancellationPending)
                {
                    e.Cancel = true; return;                    
                }
                _busy.WaitOne();

                AddTabSafeThread(link.url); 

            }
            Thread.Sleep(1000); 

            SearchSafeThread(ListToSearch); 
       }


private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {   //Check Stuff Error and Cancelled
            if (e.Error != null)
            {... }
            else if (e.Cancelled)
            { ....}
            else //Else remove all tab
            {  
              bool canRemove = this.TabCount >= 1;
            if (canRemove)
            { 
                WebBrowserTabPage tab = this.SelectedWebBrowserTagPage; 
                this.TabPages.Remove(tab);
                tab.Dispose();
            }

             **Start.Back.PerformClick();** //Click on button again to start another time the backgroundworker 
}
    private void AddTabSafeThread(Browser tempBrowser)
    { 
        if (this.tabs.InvokeRequired)   //TabControl is tabs
        {

        this.tabs.Invoke(new m_SafeTab(AddTabSafeThread), new object[] { tempBrowser });
        }
        else
         //in TabControl Class i create the WebBrowser And i call Navigate
        {   this.tabs.addTab(tempBrowser.url);    
              //Do Stuff
        }
.net
browser
backgroundworker
asked on Stack Overflow Jan 22, 2012 by user1107078 • edited May 23, 2017 by Community

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0