Please HELP :: webbrowser within background worker [modified]
-
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 -
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, 2006Why don't you register to the
WebBrowser.DocumentCompleted
event instead of actively waiting for theReadyState
property to becomeComplete
.? 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 ofApplication.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
-
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 -
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