0
        lock (lockVar)
        {

            if (done)
                return;

            if (linksvisited.Contains(webBrowser1.Url.OriginalString))
                return;

            System.Console.WriteLine("Locked: " + webBrowser1.Url.OriginalString);

            linksvisited.Add(webBrowser1.Url.OriginalString);
        }
            webBrowser1.Navigate(nextLink, null, null, "User-Agent: Googlebot/2.1 (+http://www.google.com/bot.html)");

I am using the following code to iterate through a page, but sometimes the webbrowser control will just stop and it won't go to the next page. No exceptions no anything it will just stop, but there is definitely another link it can visit. I am thinking it has something to do with an internal error in the control, but how the heck to I trap it. None of my exception handler catch anything. Nothing in the output console. I have disabled scripting errors.

SamFisher83
  • 3,937
  • 9
  • 39
  • 52
  • Have you tried using nested ifs inside your lock rather than returning? It's possible that it's returning and not unlocking because it never reached the end of the lock structure? – Rob G Apr 07 '13 at 18:21
  • 1
    I don't think that is the issue: http://stackoverflow.com/questions/1359184/can-i-put-a-return-statement-inside-a-lock – SamFisher83 Apr 07 '13 at 18:27

1 Answers1

0

Where is that code-snippet located? If you have it in an event-handler of the control - it is extremely possible that you are dead-locking yourself. As the Web Browser control can (and will fire) multiple events during the various stages of page load.

The document complete will fire for every frame on the page. (Stack OverFlow)

It is also difficult to comment on an incomplete section of code. I would read (Locking) to understand the intrinsics before continuing too much further. Good luck with your current endeavor.

Community
  • 1
  • 1
adelpreore
  • 61
  • 1
  • 5
  • It is actually in the document loaded handler. The lock statement should get translated to a try finally so it shouldn't end up dead locked – SamFisher83 Apr 07 '13 at 18:35