Announcement

Collapse
No announcement yet.

Odd Behavior of DIALOG DOEVENTS with PB 8.03

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    > By the way, SLEEP 5000 = 5 sec.
    >SLEEP 30000 = 5 min.

    Whoa. I have simply GOT to start reading the "What's New" more carefully. ()

    BTW..
    > I´ve read a lot about the deeds of SLEEP I rather use another method

    ???

    AFAIK, SLEEP() is efficient. My point was more "why check every (less than five minutes)" if you are not going to do anything EXCEPT every five minutes?

    Leave a comment:


  • Pedro Ramirez
    replied
    Originally posted by Michael Mattias View Post
    SLEEP 5000 instead of checking every 1 millisecond?

    MCM
    You may have a point there but since I´ve read a lot about the deeds of SLEEP I rather use another method.

    No, the program does not have any dialogs or windows. I just stays in memory checking for the other program. It is a security program that takes action when it does not detect the other program in memory.

    By the way, SLEEP 5000 = 5 sec.
    SLEEP 30000 = 5 min.

    I may use DIALOG DOEVENTS 1000 or DIALOG DOEVENT 30000 instead. Whatever works best.

    Thanks for your input.

    Leave a comment:


  • Michael Mattias
    replied
    ' Wait 5 minutes to check again
    SLEEP 5000 instead of checking every 1 millisecond?

    If there is a user interface here (code not shown), run this wait in a separate thread of execution...
    OR
    Use Waitable Timer Object Demo June 2005

    In either case, there is no longer any concern about DIALOG DOEVENTS defaults or CPU usage or any of that.


    MCM

    Leave a comment:


  • keith shelton
    replied
    No problem, when I can answer a question, I am happy to do it.
    KS

    Leave a comment:


  • Pedro Ramirez
    replied
    Yes, that did it. I should have researched a little bit more before posting.
    Thanks Keith.

    Leave a comment:


  • keith shelton
    replied
    From BOB ZALE
    "In PowerBASIC 8.04, the DIALOG DOEVENTS statement assumes an incorrect default value of zero (0) for the optional SLEEP& parameter. The correct default value should actually be one (1). This would cause execution to pause for 1 millisecond if there are no pending messages to process.

    We recommend that all existing code be changed to add an explicit SLEEP& value of one (1) to all DIALOG DOEVENTS statements in your programs.

    DIALOG DOEVENTS 1 -or-
    DIALOG DOEVENTS 1 TO count&

    This will allow your programs to compile and execute correctly with both current versions and future versions of PowerBASIC. The correct default value for this parameter will be used in the next release of this compiler."


    This was posted to the powerbase forum on Oct 21, 2007.
    KS



    Leave a comment:


  • Pedro Ramirez
    started a topic Odd Behavior of DIALOG DOEVENTS with PB 8.03

    Odd Behavior of DIALOG DOEVENTS with PB 8.03

    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?

    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
Working...
X
😀
🥰
🤢
😎
😡
👍
👎