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. Please HELP :: webbrowser within background worker [modified]

Please HELP :: webbrowser within background worker [modified]

Scheduled Pinned Locked Moved C#
helpcom
4 Posts 4 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.
  • N Offline
    N Offline
    Nadia Monalisa
    wrote on last edited by
    #1

    Hi, Within my background worker's DO_WORK method, I have following code, ...................................................... webBrowser1.navigate("http://www.google.com"); while(weBrowser1.ReadyState != RedyState.Complete) Application.DoEvents() .................................................... Now, when the background worker is being executed, webbrowser1 is being loaded with the mentioned website nicely without any problem. But the problem is, when it checks the ReadyState, it stays uninitialized forever and never reaches ReadyState.Complete and thus, the thread never exists. I checked the code with so many website url so there is no chance that I am having problem to load google.com. I dont have this problem when the same code is being executed in the standard main thread. Only problem when the code is being run in a background worker thread. Please help... and your co-operation is appreciated. Emran -- modified at 3:23 Sunday 5th November, 2006

    S B M 3 Replies Last reply
    0
    • N Nadia Monalisa

      Hi, Within my background worker's DO_WORK method, I have following code, ...................................................... webBrowser1.navigate("http://www.google.com"); while(weBrowser1.ReadyState != RedyState.Complete) Application.DoEvents() .................................................... Now, when the background worker is being executed, webbrowser1 is being loaded with the mentioned website nicely without any problem. But the problem is, when it checks the ReadyState, it stays uninitialized forever and never reaches ReadyState.Complete and thus, the thread never exists. I checked the code with so many website url so there is no chance that I am having problem to load google.com. I dont have this problem when the same code is being executed in the standard main thread. Only problem when the code is being run in a background worker thread. Please help... and your co-operation is appreciated. Emran -- modified at 3:23 Sunday 5th November, 2006

      S Offline
      S Offline
      Stefan Troschuetz
      wrote on last edited by
      #2

      Why don't you register to the WebBrowser.DocumentCompleted event instead of actively waiting for the ReadyState property to become Complete.? It's always complicated to access visual controls from threads other the one they were created on. Take a look at this article to get a general idea how to bypass. What's up with BeginInvoke?[^] Furthermore the call of Application.DoEvents from a worker thread isn't necessary as the use of the worker thread already keeps your application responsive (in a much nicer way than DoEvents).


      "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

      www.troschuetz.de

      1 Reply Last reply
      0
      • N Nadia Monalisa

        Hi, Within my background worker's DO_WORK method, I have following code, ...................................................... webBrowser1.navigate("http://www.google.com"); while(weBrowser1.ReadyState != RedyState.Complete) Application.DoEvents() .................................................... Now, when the background worker is being executed, webbrowser1 is being loaded with the mentioned website nicely without any problem. But the problem is, when it checks the ReadyState, it stays uninitialized forever and never reaches ReadyState.Complete and thus, the thread never exists. I checked the code with so many website url so there is no chance that I am having problem to load google.com. I dont have this problem when the same code is being executed in the standard main thread. Only problem when the code is being run in a background worker thread. Please help... and your co-operation is appreciated. Emran -- modified at 3:23 Sunday 5th November, 2006

        B Offline
        B Offline
        Bradml
        wrote on last edited by
        #3

        bashiwala wrote:

        while(weBrowser1.ReadyState != RedyState.Complete)

        Should that not be ReadyState.Complete?

        1 Reply Last reply
        0
        • N Nadia Monalisa

          Hi, Within my background worker's DO_WORK method, I have following code, ...................................................... webBrowser1.navigate("http://www.google.com"); while(weBrowser1.ReadyState != RedyState.Complete) Application.DoEvents() .................................................... Now, when the background worker is being executed, webbrowser1 is being loaded with the mentioned website nicely without any problem. But the problem is, when it checks the ReadyState, it stays uninitialized forever and never reaches ReadyState.Complete and thus, the thread never exists. I checked the code with so many website url so there is no chance that I am having problem to load google.com. I dont have this problem when the same code is being executed in the standard main thread. Only problem when the code is being run in a background worker thread. Please help... and your co-operation is appreciated. Emran -- modified at 3:23 Sunday 5th November, 2006

          M Offline
          M Offline
          mertkan65
          wrote on last edited by
          #4

          May be the problem is using " Application.DoEvents()" in the delegate function. Using this method outside of the delegate function or DoWork method may be useful ;)

          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