CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2017
    Posts
    23

    Wait for complete sit load in IE WebBrowser control

    Hello.
    I'm trying to tell my program to wait until website isn't fully loaded before continuing.
    I tried already:
    WebBrowser.IsBusy, but it doesn't work. It freezes my program very often, and didn't work properly even one time.
    while (WebBrowser.DocumentCompleted != (WebBrowserDocumentCompleted) 1) freezes my program too.
    Only WebBrowserDocumentCompletedEvent works fine, but it's called even 7 times when website is loading, otherwise i don't know how to tell my function to wait on response from this event.

    Is there any other solution?
    Thank you a lot for your advices!
    Greetings, genotypek.

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Wait for complete sit load in IE WebBrowser control

    Looks like the event gets fired once for each of seven frames making up your complete page. In this case, I think, you should be able to identify the frame you're actually interested in by the Url property of the event args parameter passed to your handler.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Apr 2017
    Posts
    23

    Re: Wait for complete sit load in IE WebBrowser control

    Okay, but what to do, if I'm not completely sure what is this properly url of this site which my IE is loading?
    And in this case, how to make communication between my event and my part of code?
    Greetings.

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Wait for complete sit load in IE WebBrowser control

    There's a good chance that the URL of interest is the one you navigated to. Content hosted in frames typically is something like navigation sidebars or ads, for example.

    As far as I recall, the document completed event handler is invoked on the GUI thread, so you can do practically anything you want in your event handler, including GUI updates, or call methods of your own that do. To make really sure that you're running on the GUI thread, you can put this line at the beginning of your event handler (assuming you have a using namespace System::Diagnostics; in the respective source file):

    Code:
    Debug::Assert(!InvokeRequired);
    Try to avoid long-running processes (like polling loops), though, because that blocks the GUI thread and freezes your application, as you have seen.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured