Results 1 to 6 of 6

Thread: Timer Speed Up

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Posts
    124

    Timer Speed Up

    I'm current using a timer with an interval of 1000ms.

    This timer is created and disposed many times throughout the life of the program via the capture of Alt and C buttons respectively. I dont know if this has any relevance but im using global hooks to start/stop the timer when the form isnt in focus to capture those key down events (for some reason Alt doesnt raise a key press, only a key down.)

    After a few creations/disposes it seems the timer interval drastically reduces and approaches 1ms.

    i've tried resetting the interval time everytime i create the instance of the timer but that doesnt seem to work.

    the timer tick is firing a mouse_event of left button down then after another tick, mouse_vent of left button up.

    I've also setup a way to check the interval value and the object always reports it to be 1000ms..which is impossible as i can see the mouse selecting and double clicking anything it comes into contact with. (which should be impossible since i've used the SetDoubleClickTime(1))

    any help would be greatly appreciated

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: Timer Speed Up

    How about this :
    http://www.vbforums.com/showthread.p...ighlight=timer
    I know it's API function but it'd be more faster and has lower system overhead than using the timer component .

  3. #3
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Timer Speed Up

    It would be helpfull if you could post some of your code.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Timer Speed Up

    Why should your Timer be created and destroyed repeatedly? All you need to do is use a single Timer object and call its Start and Stop methods I would have thought. Also, I'd avoid using Alt+<anything> as a keyboard hook because that could have specific meaning in other apps if it is a mnemonic. Ctrl+Alt+<something> is less likely to be meaningful to other apps.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2003
    Posts
    124

    Re: Timer Speed Up

    i originally had the timer being stopped and started using the myTimer.Start() and myTimer.Stop() methods. I thought that the object was getting its properties corrupted somehow so i decided to create/destroy on each use, to no avail.

    I have since switched back to the Stop and Start.

    The code regarding the high accuracy time span is interesting and i will try it out when i get home.

    Since posting i've added a logger to see if there was any logic to the interval decreasing..and it seems that the interval was decreasing by exactly 50% eachtime the timer was disposed/created. I think a possibility is that i have multiple timers firing off tick events and only one method firing on those different timers ( i dont know if thats even possible..but im ready to consider anything right now ).

    I'm at work and can't access my code but ill rewrite what i have from scratch for the guy requesting the code.

  6. #6
    Fanatic Member
    Join Date
    May 2005
    Posts
    898

    Re: Timer Speed Up

    Looks like you just answered your own question, you haven't disposed the timer properly.
    "so just keep in mind that fantasy is not the same as realtiy and make sure u remember that wii sports may be fun but u cant count on it as exercise ok cool bye" - HungarianHuman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width