|
-
Nov 19th, 2002, 09:52 AM
#1
Thread Starter
Hyperactive Member
CPU usage during GameLoop
Wow! I found out that during the "GameLoop" Cpu usage is 100%. There are needs/ways to make this value smalller???
this is the code for gameloop:
VB Code:
While GameRunning
'DoSomestuffhere
CheckIfIHaveToExitThisLoop 'for stopping gameloop
DoEvents
Wend
Thx,
Xmas
Learn, this is the Keyword...
-
Nov 19th, 2002, 12:27 PM
#2
I don't think that te loop you posted is causing the 100% CPU usage.
The code you show would allows other application to step (DoEvents).
I guess your code for timehandling (if you have something like that) is the problem, are you using the Timer Control?
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
Nov 19th, 2002, 01:57 PM
#3
Thread Starter
Hyperactive Member
No, I'm not using Timer Control
I just tried to create a new project and put this code in:
VB Code:
Option Explicit
Dim GameRunning As Boolean
Private Sub Form_Load()
Me.Show
GameRunning = True
While GameRunning
DoEvents
Wend
End Sub
'Exit loop when closing form
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
GameRunning = False
End Sub
This code still gets 100% of CPU load.
The program that says 100% of CPU load is the Norton System Doctor. Win98 SE.
The doevents lets my application and VB IDE to step (I think). Other application always will step, even without it.
Thx
Xmas.
Learn, this is the Keyword...
-
Nov 19th, 2002, 03:27 PM
#4
Addicted Member
Yes, the CPU usage is 100%. But that doesn't mean that you can't use the CPU anymore. If another program wants time on the cpu, it will get it, because of the doevents statement. However, whenever there is a time where no other program is using the cpu, your program is using it, and therefore it is 100%. I think that you will not acutally notice any speed decrease in other programs while your running your program. Your program uses all the cpu when it can, but it will always yield to others because of the doevents. i don't think its a problem.
-
Nov 19th, 2002, 03:31 PM
#5
Thread Starter
Hyperactive Member
Yes, in fact I didn't noticed any performance loss...
Thanks a lot,
Xmas.
Learn, this is the Keyword...
-
Nov 19th, 2002, 04:04 PM
#6
Good Ol' Platypus
When you do a loop, it takes all AVAILABLE power. Think of this as being very low-priority; if another application wants the CPU time, VB simply takes less CPU %, and thus more time. This is the same principle why having 2 graphics applications open at one time (say, 3DSMax and Half-Life) will really start to slow down your computer.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
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
|