|
-
May 25th, 2004, 12:16 PM
#1
Thread Starter
New Member
Is there something less Processor intensive then DoEvents?
I have a program that needs to wait for a web page to load completely. I do this by setting a global boolean variable when the document = DocumentComplete.
VB Code:
Public Function GotoWebPage(vWebPage as string) as boolean
wb.Navigate = vWebPage
wpReadyFlag = False
Do While wpReadyFlag = False
DoEvents
Loop
End Function
Private Sub wb_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If wb.ReadyState = READYSTATE_COMPLETE Then
wpReadyFlag = True
End If
End Sub
When this runs (and it runs many many times) the processor spikes to 100% for the duration of the page load. Is there something else I can do instead of "DoEvents"?
-
May 25th, 2004, 01:57 PM
#2
Addicted Member
Call the sleep api instead.
Here:
VB Code:
''Put the app to sleep for a bit...
'http://www.vbexplorer.com/VBExplorer/time.asp
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'In your loop
Do While wpReadyFlag = False
Sleep 1000 '1 second
Loop
Last edited by madjon; May 25th, 2004 at 02:00 PM.
-
May 25th, 2004, 02:22 PM
#3
yay gay
Just put your code in the DownloadComplete event
\m/  \m/
-
May 25th, 2004, 06:36 PM
#4
I'd use the Sleep API, but I'd do it like this:
Code:
Do While wpReadyFlag = False
DoEvents ' you still want to check those events :)
Sleep 10 ' better responce time but still saves the CPU
Loop
-
May 26th, 2004, 11:16 AM
#5
Thread Starter
New Member
Aye, all good idea's but...
I've tried them all.. If I put my code in the document_complete sub it get's WAY out of hand trying to figure out what page I'm on. It sort of works but there is a lot more going on then I can put here.. SleepEX puts my whole application to bed when there are many other parts of the application running different items and other browser windows.
Thanks for the suggestions tho I do appreciate it, and I should have mentioned that I've tried those before.. my bad.
Any othere ideas?
-
May 27th, 2004, 01:21 AM
#6
Addicted Member
You could post your project for us to look at.
-
May 27th, 2004, 03:40 AM
#7
It sounds like you have another loop somewhere
-
May 27th, 2004, 02:51 PM
#8
Thread Starter
New Member
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
|