Well, this is post number 41 in this thread so if I give you a little bashing here you would at least got bashed in post 40+ LOLQuote:
Originally Posted by RobDog888
Bad code, Rob, bad bad bad bad bad :)
Printable View
Well, this is post number 41 in this thread so if I give you a little bashing here you would at least got bashed in post 40+ LOLQuote:
Originally Posted by RobDog888
Bad code, Rob, bad bad bad bad bad :)
Ah, thats more like it. :lol:
GetQueueStatus looks interesting. I'll have to check it out.
Congrats on 6K+ posts JA. :thumb:
congrats on 13,893 posts RD
In such example, if you set the Sleep to 500, does it mean there is a wasted 250 ms since it only takes about 250 ms to accomplish the loading?Quote:
Originally Posted by Joacim Andersson
It can take several seconds for a webpage to be loaded into the webbrowser object. The loop in this case checks if it's done loading every half second, so let's say that you check if it's finished, and it's not so you wait 500ms, but already 1ms after that the load was done in which case you've "wasted" 499 ms. What I meant is that on average the extra time you wait after the webbrowser is done loading would be 250ms.Quote:
Originally Posted by dee-u
HOWTO: Determine the Differences Between DoEvents and Sleep
Q158175
SUMMARY
This article explains the differences between the Visual Basic DoEvents function and
the Sleep() Windows API function.
MORE INFORMATION
DoEvents is a Visual Basic function that yields execution so the operating system can
process other events. This function cleans out the message loop and executes any other
pending business in the Visual Basic runtime. Upon completing the pending business
execution, the function calls the Sleep function with zero (0) as the argument so that
the remaining time slice can be used to check the queue.
The Sleep 32-bit API function is a subset of the DoEvents function. The Visual Basic
program calling the function and the Visual Basic runtime executable and interactions
with Windows are immediately put to sleep by this function. The programs remain inactive
for the time in milliseconds specified in the Sleep argument.
The Sleep function allows you to specify the amount of time your applications are
inactive. The DoEvents function returns control to the Visual Basic program after
the operating system has finished processing the events in its queue and all keys in
the SendKeys queue have been sent.
The information in this article applies to:
Microsoft Visual Basic Learning Edition for Windows 5.0
Microsoft Visual Basic Learning Edition for Windows 6.0
Microsoft Visual Basic Professional Edition for Windows 5.0
Microsoft Visual Basic Professional Edition for Windows 6.0
Microsoft Visual Basic Enterprise Edition for Windows 5.0
Microsoft Visual Basic Enterprise Edition for Windows 6.0
Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
Last Reviewed: 5/13/2003 (3.0)
Keywords: kbhowto KB158175
Yes, I agree; I think that DoEvents can be very dangerous. If, for instance, you have a COM Server (of which only 8, by default, instances are allowed) and you put a DoEvents in one of the function calls then you will have a nasty case of corrupt synchronisation, and get reentrancy problems.Quote:
Originally Posted by penagate
DoEvents should always be used with care, and never in any form of shared code.
The best thing to do when it comes to webbrowser is to avoid the do while and instead move your code to the documentcomplete event and maybe sort your code based on where the browser is one example is
in documentcomplete event
select case Webbrowser1.document.title
case "google"
'Do some search stuff with google
case "UPC database"
'Enter a upc
end select
using this way will completely free up the application until page is loaded
and also you can trap 404 pages and other error pages by title