|
-
Dec 6th, 2000, 01:57 PM
#1
Thread Starter
Junior Member
I have a VB application which has an inifinte loop. The loop may not be doing anything at times but consumes upto 99% CPU during that time. Even if I have Sleep/DoEvents the CPU consumption is upto 65 - 70%.
Please let me know how to make programs mor CPU efficient
to improve performance
Thanks
-
Dec 6th, 2000, 02:38 PM
#2
Frenzied Member
what your infinite loop use?
show your code, maybe there's a work around
-
Dec 6th, 2000, 02:56 PM
#3
Thread Starter
Junior Member
My loop is
Do While (True)
Sleep (10)
'some processing
Loop
Public Sub Sleep(PauseTime As Integer)
Dim start As Double
start = Timer ' Set start time.
Do While Timer < start + PauseTime
DoEvents ' Yield to other processes.
If Timer < 50 Then
start = Timer
End If
DoEvents
Loop
End Sub
while it is processing the CPU is 2 or 3. But when idle it consumes all the CPU
Thanks
-
Dec 6th, 2000, 03:25 PM
#4
Frenzied Member
i'm saying, why it has to be infinite loop,explain!!
-
Dec 6th, 2000, 03:35 PM
#5
Lively Member
Try this:
Code:
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Sub DoInFiniteLoop()
Do While (True)
DoEvents
Sleep (10)
'some processing
Loop
End Sub
-
Dec 6th, 2000, 03:36 PM
#6
Thread Starter
Junior Member
Since it is an unattended process supposed to be performed
all the time
thanks
-
Dec 6th, 2000, 09:55 PM
#7
Frenzied Member
SargumSingh, did you receive my email??
-
Dec 7th, 2000, 09:01 AM
#8
Thread Starter
Junior Member
I'm now using the sleep API instead of VB Timer function.
It just works great. Now the app really looks like sleeping
consuming 00 CPU.
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
|