Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Loading Webpage - Wait until page is loaded

Loading Webpage - Wait until page is loaded

Scheduled Pinned Locked Moved C#
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Seraphin
    wrote on last edited by
    #1

    I am using this code for check webbrowser's activity while (wbr.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } But when I am using heForm.InvokeMember("submit"); which submits a form on a webpage, ReadyState will not be activated or changed. Also the IsBusy flag doesn't change.

    J 1 Reply Last reply
    0
    • S Seraphin

      I am using this code for check webbrowser's activity while (wbr.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } But when I am using heForm.InvokeMember("submit"); which submits a form on a webpage, ReadyState will not be activated or changed. Also the IsBusy flag doesn't change.

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      I wouldn't do that. Application.DoEvents is terribly inefficient, causes many allocations and can result in unexpected scenarios. Instead, just listen for the wbr.Navigating event, which will tell you when the browser's busy. I believe there's a DocumentCompleted event to tell you when the document is fully loaded.

      Tech, life, family, faith: Give me a visit. I'm currently blogging about: Bought a House! Judah Himango

      S 1 Reply Last reply
      0
      • J Judah Gabriel Himango

        I wouldn't do that. Application.DoEvents is terribly inefficient, causes many allocations and can result in unexpected scenarios. Instead, just listen for the wbr.Navigating event, which will tell you when the browser's busy. I believe there's a DocumentCompleted event to tell you when the document is fully loaded.

        Tech, life, family, faith: Give me a visit. I'm currently blogging about: Bought a House! Judah Himango

        S Offline
        S Offline
        Seraphin
        wrote on last edited by
        #3

        Hi Judah, thx for reply and this tip. But additionally this won't work with InvokeMember. After firing this code line the application doesn't recognize browser activity.

        P 1 Reply Last reply
        0
        • S Seraphin

          Hi Judah, thx for reply and this tip. But additionally this won't work with InvokeMember. After firing this code line the application doesn't recognize browser activity.

          P Offline
          P Offline
          peshkunta
          wrote on last edited by
          #4

          Not sure if this is what you are looking for. The following example shows some of my code I've used where I have a timer event handler function call this piece of code every second. Without the if statement this would cause problems because the page doesn't always load in the browser at the same speed - it will make the program stop responding. But with the if statement this checks and makes sure the WebBrowser object is not loading anything at the moment and if it is, it doesn't execute the code (doesn't load anything else - until the statement is true): if (webBrowser1.IsBusy == false && webBrowser1.IsOffline == false) { webBrowser1.Url = new Uri(strUrl); } Let me know if I can help further.

          S 1 Reply Last reply
          0
          • P peshkunta

            Not sure if this is what you are looking for. The following example shows some of my code I've used where I have a timer event handler function call this piece of code every second. Without the if statement this would cause problems because the page doesn't always load in the browser at the same speed - it will make the program stop responding. But with the if statement this checks and makes sure the WebBrowser object is not loading anything at the moment and if it is, it doesn't execute the code (doesn't load anything else - until the statement is true): if (webBrowser1.IsBusy == false && webBrowser1.IsOffline == false) { webBrowser1.Url = new Uri(strUrl); } Let me know if I can help further.

            S Offline
            S Offline
            Seraphin
            wrote on last edited by
            #5

            Hi peshkunta, After InvokeMember (new in .NET Framework 2.0) -> IsBusy = false IsOffline = false that's the problem (tested with your code above as check process) InvokeMember fire a method of the selected HTML element. I loaded a FORM tag and after submitting it, a new webpage is loaded again. But if I am in debugging mode and go to the line after InvokeMember I wait a moment and then it works, because the browser don't fire the flag immediately.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups