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. Wait for program to continue till webbrowser finish loading site

Wait for program to continue till webbrowser finish loading site

Scheduled Pinned Locked Moved C#
help
4 Posts 2 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.
  • U Offline
    U Offline
    User 4414712
    wrote on last edited by
    #1

    Hey. I am having a program where I am navigating a site, but the program continiues before the site is done loading, which means I get errors in the program. I have tried: wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler( delegate { //MyCode } ); But the program still contiunues, and then returns back to that function it is done loading, and that still gets me error. I also tried private void Navigate2(String address) { if (String.IsNullOrEmpty(address)) return; if (address.Equals("about:blank")) return; if (!address.StartsWith("http://") && !address.StartsWith("https://")) { address = "http://" + address; } try { webBrowser1.Navigate(new Uri(address)); } catch (System.UriFormatException) { return; } } But that aint waiting neither for the site to finish loading. Can anyone help me please :)

    C 1 Reply Last reply
    0
    • U User 4414712

      Hey. I am having a program where I am navigating a site, but the program continiues before the site is done loading, which means I get errors in the program. I have tried: wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler( delegate { //MyCode } ); But the program still contiunues, and then returns back to that function it is done loading, and that still gets me error. I also tried private void Navigate2(String address) { if (String.IsNullOrEmpty(address)) return; if (address.Equals("about:blank")) return; if (!address.StartsWith("http://") && !address.StartsWith("https://")) { address = "http://" + address; } try { webBrowser1.Navigate(new Uri(address)); } catch (System.UriFormatException) { return; } } But that aint waiting neither for the site to finish loading. Can anyone help me please :)

      C Offline
      C Offline
      Calin Tatar
      wrote on last edited by
      #2

      you may use ProgressChanged event, and check for e.CurrentProgress and e.MaximumProgress Calin

      U 1 Reply Last reply
      0
      • C Calin Tatar

        you may use ProgressChanged event, and check for e.CurrentProgress and e.MaximumProgress Calin

        U Offline
        U Offline
        User 4414712
        wrote on last edited by
        #3

        Thx very much.. I used these functions you mentioned and then a global variable.. private void Navigate2(String address) { if (String.IsNullOrEmpty(address)) return; if (address.Equals("about:blank")) return; if (!address.StartsWith("http://") && !address.StartsWith("https://")) { address = "http://" + address; _loaded = false; webBrowser1.Navigate(address); webBrowser1.ProgressChanged += new WebBrowserProgressChangedEventHandler(webBrowser_ProgressChanged); while (_loaded == false) { Wait(100); } return; } } private void webBrowser_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e) { siteLoading.Value = (int)e.CurrentProgress; if (e.CurrentProgress >= e.MaximumProgress) { Wait(200); _loaded = true; ; } }

        C 1 Reply Last reply
        0
        • U User 4414712

          Thx very much.. I used these functions you mentioned and then a global variable.. private void Navigate2(String address) { if (String.IsNullOrEmpty(address)) return; if (address.Equals("about:blank")) return; if (!address.StartsWith("http://") && !address.StartsWith("https://")) { address = "http://" + address; _loaded = false; webBrowser1.Navigate(address); webBrowser1.ProgressChanged += new WebBrowserProgressChangedEventHandler(webBrowser_ProgressChanged); while (_loaded == false) { Wait(100); } return; } } private void webBrowser_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e) { siteLoading.Value = (int)e.CurrentProgress; if (e.CurrentProgress >= e.MaximumProgress) { Wait(200); _loaded = true; ; } }

          C Offline
          C Offline
          Calin Tatar
          wrote on last edited by
          #4

          Cool! Calin Tatar

          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