|
You should probably think again about *why* you want to do this.
The purpose of "doevents" in VB and similar languages is not to release CPU to other process, it is specfically to allow event handling threads in the same process to execute. These threads may be blocked while a piece of code is executing. For instance, you may update a counter on a web form, but it won't display because the thread which handles the display update cannot execute until your function exits. In this case, "doevents" will allows the thread to execute.
The Windows kernels use scheduling tactics to ensure that all processes get a bit of the CPU. The scheduler will allocate more CPU to certain processes depending on their permissions, priority and the way that they execute.
All this means that if you are giving up CPU in a running process you are simply wasting time that your script could be processing. A CPU not running at 100% is a wasted CPU.
NB One caveat to this, the Win9x kernels are poorly designed as far as process handling, and can perform appallingly where you have a process hog.
The correct solution if you are worried about processor load is to give the job a lower priority.
There are a few ways to do this, but the easiest is using the DOS "START" command with the "/LOW" or "/BELOWNORMAL" switch. This will allow your script to have as much CPU as it wants where available, but the scheduler will give it a smaller piece of the CPU pie when there is contention. [ 18. September 2003, 09:58: Message edited by: Richard H. ]
|