I have a program that sits in memory checking for the continuous presence of another program which must be running and which has setup its Mutex.
The code below shows what this program does while doing nothing. It just executes a loop, counting down the time lapsed until it is time to check again. In order to minimize CPU use I use the DIALOG DOEVENTS statement.
IF I compile this program with PB 7.04 it works nice. The CPU use as reported by the task administrator is 00. IF However I compile it using PB 8.04 the CPU use goes up to 99 in slow computers and somehow lower in faster computers. I haven´t installed PB 9.00 yet.
Any suggestions?
The code below shows what this program does while doing nothing. It just executes a loop, counting down the time lapsed until it is time to check again. In order to minimize CPU use I use the DIALOG DOEVENTS statement.
IF I compile this program with PB 7.04 it works nice. The CPU use as reported by the task administrator is 00. IF However I compile it using PB 8.04 the CPU use goes up to 99 in slow computers and somehow lower in faster computers. I haven´t installed PB 9.00 yet.
Any suggestions?
Code:
VerifyAgain: ' Check for Mutex lpClassName = $MUTEX_SEGURIDAD1 lResult = App_PrevInstance(lpClassName) ' If the program we are checking is running, do nothing, wait, and check again. IF lResult <> 0 THEN ' PROGRAM IS IN MEMORY OriginalmenteEnMemoria = 1 ' Wait 5 minutes to check again InitialTime = TIMER DO CurrentTime = TIMER DIALOG DOEVENTS IF CurrentTime - InitialTime > PermanentWait THEN ' Once the wait time is up, check again GOTO VerifyAgain END IF LOOP END IF
Comment