Ho un problema con il mio programma Modulo WinApp che contiene una scheda Controllo con DLL controllo WebBrowser (GeckoFX).Arresto modulo WinApp senza errori o eccezioni .Net
La mia applicazione è in esecuzione senza eccezioni o altro. Potrebbe succedere dopo pochi minuti o dopo max 10 minuti. Nello studio visivo vedo l'applicazione terminare con il codice 0. Qualsiasi cosa.
Nel Program.cs prendo tutto questo excpetion non gestita
` // 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);`
ho già Check in logger eventi Windows per qualsiasi errore, ma è pulito. Proprio come il Programma è terminato bene. Non so se è colpa di Gecko DLL ma non la penso così.
Uso httpWebRequest per scaricare un elenco che contiene alcuni URL.
Quindi utilizzo un Backgroundworker
che legge l'elenco dell'URL e richiama il metodo Delegato AddTab Sospendi un po 'fino a quando la pagina non viene caricata e continua con altri richiami di AddTab.
Quando l'elenco è vuoto mi controllare se nella pagina DOM v'è una certa stringa Poi nel Backgroundworker
Complete I chiudere tutte le schede e li smaltire e clicco su button1 cui avviare il Backgroundworker1.asyncall();
C'è qualcosa di sbagliato con la mia logica? Pubblicherò anche il codice, ho bisogno che sia troppo lungo ma ho davvero bisogno di capire dove potrebbe essere l'errore che termina la mia domanda. Se qualcuno può aiutarmi a capire perché si blocca senza alcun errore o altro, lo apprezzerò.
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
}
}
Molto improbabile che tu abbia effettivamente un errore o un'eccezione.Il codice è abbastanza infelice, in nessun modo Start.Back.PerformClick() potrebbe funzionare. E nessuno del codice BGW viene effettivamente eseguito sul thread di lavoro. Aggiungi un gestore di eventi per l'evento FormClosing del modulo e imposta un punto di interruzione su di esso. –
Whay suggerisci di creare un codice migliore? Potrebbe dirmi come posso gestirlo? Creo il BackGroundworker e poi? Come posso riavviare il backgroundworker una volta terminato? Apprezzerò se puoi dirmi come potrei scrivere un codice migliore :) – user1107078
possibile duplicato di [Arresti applicazioni con "Errore interno in .NET Runtime"] (http://stackoverflow.com/questions/4367664/application- si blocca-con-errore-interno-nella-rete-runtime) –