|
-
Oct 10th, 2000, 09:04 AM
#1
Thread Starter
Lively Member
I've seen on these boards a lot that people have been criticized for using DoEvents in a loop. Why is this bad? To me it sounds like a good idea to give control back to Windows temporarily to let it catch up on what it needs to do.
Also, I have a loop in one of my programs that updates a progress bar. Well the progress bar won't graphically show the updates unless I have a doEvents statement in there.
Is there another way to get it to graphically update?
Many thanks!
-
Oct 10th, 2000, 09:15 AM
#2
transcendental analytic
Doevents actually only concerns your program not any others. The bad thing about doevents is that it hangs up your app if called after all forms are unloaded.
Doevents updates the graph? yeah that because a WM_Paint message is queing for being processed by your app
Well a good way to avoid probs with doevents is to check if there are any forms left.
Code:
'for a loop
Do while forms.count
doevents
'code
loop
'and another one
Do
'code
doevents
Loop while forms.count
'and other frequently used code
If forms.count then doevents
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 10th, 2000, 09:40 AM
#3
Fanatic Member
It's kinda bad to use doevents to redraw the progress bar, this code is faster:
Code:
ProgressBar.Refresh
The code is faster then doevents, because doevents gives every program a chance to do something.
-
Oct 10th, 2000, 09:52 AM
#4
transcendental analytic
Not really, doevents gives only your program a chance to handle it's message queue, that's if the progressbar is the only thing to update, then it will update without any other process being executed
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 10th, 2000, 09:54 AM
#5
Thread Starter
Lively 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
|