Delay an Application Until a Specified Condition is True II
Category:
MiscellaneousType:
ModulesDifficulty:
AdvancedAuthor:
Jens NeuhalfenVersion Compatibility: Visual Basic 5
More information:
I just read "Delay an Application Until a Specified Condition is True" and found a problem: the DoEvents loop consumes lots of
processor time because it's *polling* for messages/state changes.
This is absolutely unperfomant and *not* threadsafe.
A better way is to use Win32API-Events.
A quick test of the while not bCancel:DoEvents:wend method showed 97% processor usage on WinNT 4.0 / 233Mhz! My method uses only "normal" processing time.
Instructions: Copy the declarations and code below and paste directly into your VB project.
Declarations: