WinApp表单崩溃没有任何错误或异常.Net

use*_*078 12 .net c# exception winforms

我的MyApp Form程序有一个问题,它包含一个带WebBrowser控件DLL(GeckoFX)的选项卡Control.

我的应用程序在关闭时没有任何异常或任何东西.它可能在几分钟后或10分钟后最大值发生.在visual studio中,我看到应用程序以代码0终止.任何事情.

在program.cs中,我抓住了所有这些未处理的重复

` // Add the event handler for handling UI thread exceptions to the event.
                 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(UIThreadException);

  // Set the unhandled exception mode to force all Windows Forms errors to go through
    // our handler.
                  Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

 // Add the event handler for handling non-UI thread exceptions to the event. 
                 AppDomain.CurrentDomain.UnhandledException +=
                     new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);`
Run Code Online (Sandbox Code Playgroud)

我已经在Windows事件记录器中检查是否有任何错误,但它很干净.就像程序终止得好.我不知道它是否是Gecko DLL故障,但我不这么认为.

我使用httpWebRequest下载包含一些URL的列表.

然后我使用a Backgroundworker读取URL列表,并调用addTab Delegate Method Sleep,直到加载页面并继续其他AddTab Invoke.

当列表为空时,我检查在DOM页面中是否有某个字符串然后在Backgroundworker完成我关闭所有选项卡并处理它们然后我点击button1启动Backgroundworker1.asyncall();

我的逻辑有什么问题吗?我也会发布代码,我需要它太长但我真的需要了解哪里可能是终止我的应用程序的错误.如果有人可以帮我看看为什么它崩溃没有任何错误或任何我会欣赏的.

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();

                if (tabs.InvokeRequired)
                { 
                        m_addTab addTabInvoke = addTabUrl;
                       Invoke(addTabInvoke, new Object[] { link.url, link.StringToSearch }); 
                }
            } 
            Thread.Sleep(2000); 
            if (tabs.InvokeRequired)
            { 
                foreach (Browser tempBrowser in ListCurrentBrowser)
                {
                    if (backgroundWorker1.CancellationPending)
                    {
                        e.Cancel = true;
                        return;
                    }
                    _busy.WaitOne();
                    Thread.Sleep(1000);
                    m_SeachTab addSearchInvoke = addTabPSearch;
                    Invoke(addSearchInvoke, tempBrowser); 
                }
            }
        }

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
}
Run Code Online (Sandbox Code Playgroud)

}

the*_*ric 0

实际上,当另一个线程中发生未处理的异常时,整个进程都会终止。您需要在调试下运行应用程序,同时设置“调试”/“异常”/“公共语言运行时异常”两个复选框。