|
-
Oct 25th, 2012, 11:47 PM
#1
[RESOLVED] Wait for WebBrowser WebBrowserReadyState.Complete when no async CallBack can be used
The App i'm working with has no Form, it's just a single instance Run Application, it runs and closes, so i can't catch asyncronic events thrown by Webbrowser, i've used Document_Complete() event in the past but is there any alternative when there is no Form?
I know a loop like this would work, not allowing execution to continue until the state changes, but i just wanted to know if there exist something better since it's known as a bad practice in .Net:
Code:
Do While (wb.ReadyState <> WebBrowserReadyState.Complete)
Application.DoEvents()
Loop
-
Oct 26th, 2012, 12:32 AM
#2
Re: Wait for WebBrowser WebBrowserReadyState.Complete when no async CallBack can be u
It sounds like you have no choice but to use a loop but don't put Application.DoEvents inside it. There are no events to do so that doesn't do anything for you. All it does is max out the CPU usage. Put a Thread.Sleep call in there so that at least the app is doing nothing each iteration. A period of 100 will mean that you wait no longer than 1/10 of a second between when the document actually finishes loading and when you move on from the loop, which should be good enough for anyone. You could probably go to 500 or even 1000 and still not have an issue.
-
Oct 26th, 2012, 02:48 PM
#3
Re: Wait for WebBrowser WebBrowserReadyState.Complete when no async CallBack can be u
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|