2

I'm finishing (QA testing) a web parser built in C# that is parsing specific data from a web site that is being load to a webbrowser control in a WFA (Windows Form Application) program.

The weird behavior is when I'm killing the internet connection... Actually the program is designed to navigate recursively in the site and each step its waiting for a WebBrowserDocumentCompletedEventHandler to be triggered. Beside that there is a Form timer set, and if the handler is not triggered in a specific interval then its reloading the entire procedure.

Everything is working good even if I manually avoid the handler from triggering - As I said the timer kicks in and restart the operation successfully and retrying another value successfully.

When shutting the internet connection manually while the procedure is running, I can see the page is getting the internet explorer message: "This page can't be displayed" (For some reason the DocumentComplete... is not triggered). Then immediately reconnecting the internet and waiting for the timer to kick in - As expected it fires the reload function but this time everything is going wild!! the functions are being fired not in the correct order and it seems like there is 100 threads that are running at the same time - a total chaos.

I know that its not easy to answer this question without experiencing that and seeing the code But if I copy the entire code it will be just too long using 5 different classes and I really can't see where is the problem... I'll try to simplify the question:

  1. why when connection lost the documentcomplete handler don't fires?
  2. Does anyone has experienced an application going wild only after webbrowser control losses connection?

Thanks

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Shlomi Hassid
  • 6,500
  • 3
  • 27
  • 48
  • WFA? What's that then? – spender Mar 16 '14 at 17:38
  • Windows Form Application... – Shlomi Hassid Mar 16 '14 at 17:39
  • OK. You do realize, WebBrowser control is IE. Now, once a request is out of your application boundaries, it is all IE from there. However, I would expect IE to send back a notification host application which it is not doing. I am way past beer o'clock to try some code but this is my guess: IE does not raise a notification. – danish Mar 16 '14 at 17:46
  • 1) is obvious: you can't get the DocumentCompleted event when there's no document. 2) is common: programmers never test their error handling code. Write the bug, send it back. – Hans Passant Mar 16 '14 at 17:53
  • @Hans Passant - I thought that when IE is finished processing my request it will return a response regardless to which result it has - it's returning for unknown address etc... why not when connection is down? Do you have any Idea of any relationship between the application to the internet connection that may act like that? – Shlomi Hassid Mar 16 '14 at 17:57
  • @ShlomiHassid, I tried your disconnect scenario using a simple app [based on this](http://stackoverflow.com/a/22262976/1768303). The `DocumentCompleted` behavior is expected and confirmed, but I don't experience any other "wildness". Look for bugs in your test script code, or in the code you're testing. – noseratio Mar 16 '14 at 20:18
  • @Noseratio I actually think there is something very wrong with the webbrowser control... Do you think this documentCompleted is a VS bug? I found a workaround by removing the webbrowser control and replacing it with a new one every time the connection is lost (timer tick is fired) and then reloading the procedure.... so weird! – Shlomi Hassid Mar 16 '14 at 21:08
  • @ShlomiHassid, why do you think it's a bug? The document hasn't loaded, thus there's no `DocumentCompleted` fired. To retry the navigation, call `WebBrowser.Stop` then `WebBrowser.Navigate`. – noseratio Mar 16 '14 at 23:13

0 Answers0