Announcement

Collapse
No announcement yet.

SetTimer question: What is the maximum time allowed?

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

  • SetTimer question: What is the maximum time allowed?

    From the API information: If uElapse is greater than USER_TIMER_MAXIMUM, the timeout is set to 1. However I cannot find any information about the value of USER_TIMER_MAXIMUM. Can you help me? Thanks in advance.

    Best regards,

    Erik

  • #2
    Haven't seen any official figures but have seen the following a few times at several places.

    #define USER_TIMER_MAXIMUM 0x7FFFFFFF

    Comment


    • #3
      Erik,
      if you have WinXP (not SP2 or later) then you could quickly figure it out by setting a very large time and seeing if it times out in 1ms. If it does, then reduce the time and try again until it doesn't
      When it stops timing out in 1ms and starts timing out at the specified time then you've found USER_TIMER_MAXIMUM

      How high do you need it to be?
      For WinXP SP2 USER_TIMER_MAXIMUM is at least 10,000,000 and counting.. .

      Paul.

      Comment


      • #4
        Unless I misread or misunderstood. The docs say the timer uses Tickcount which under "GetTickCount" remarks
        The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if Windows is run continuously for 49.7 days.
        Long time to test but if really wanting to know, have fun with it
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #5
          A bug well known

          edit - since W95
          Last edited by Arthur Gomide; 29 Mar 2009, 07:27 PM.
          "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

          Comment


          • #6
            If you want really long delays, use GetLocalTime and SystemTimeToFileTime to get elapsed time in 100nS increments. (Just divide by 10,000,000 to get seconds)
            Regards,
            Peter

            "Simplicity is a prerequisite for reliability"

            Comment


            • #7
              According to the powerbasic API include files from Jose Roca site:
              Code:
              %USER_TIMER_MAXIMUM  = &H7FFFFFFF???
              His includes are based on a translation of the full window SDK files, so they include more than the ones that came with PB. And I have found them to be very accurate considering the amount of work involved. You might want to try them out. Note, before you will see the file attachments to download, you must sign in to his site.
              "I haven't lost my mind... its backed up on tape... I think??" :D

              Comment


              • #8
                SetTimer:
                Return Value

                If the function succeeds and the hWnd parameter is NULL, the return value is an integer identifying the new timer. An application can pass this value to the KillTimer function to destroy the timer.

                If the function succeeds and the hWnd parameter is not NULL, then the return value is a nonzero integer. An application can pass the value of the nIDEvent parameter to the KillTimer function to destroy the timer.

                If the function fails to create a timer, the return value is zero. To get extended error information, call GetLastError.
                Code:
                  FOR Z = 1 to %some_big_number
                      iRet = SetTimer (hWnd, %ID_TIMER, Z, %NULL) 
                      IF ISTRUE iRet THEN 
                           ' timer created, so destroy it 
                           KillTimer    hWnd, %ID_TIMER
                      ELSE
                         MSGBOX  "Can't create TIMER, I guess Z is too large!" 
                
                ....
                ???
                Michael Mattias
                Tal Systems (retired)
                Port Washington WI USA
                [email protected]
                http://www.talsystems.com

                Comment


                • #9
                  Thanks a lot for your fine information and suggestions. It is very helpful.

                  Best regards,

                  Erik

                  Comment

                  Working...
                  X