Results 1 to 10 of 10

Thread: [RESOLVED] What happens when a timer is enabled but..

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Wisconsin
    Posts
    788

    Resolved [RESOLVED] What happens when a timer is enabled but..

    What happens when a timer is enabled but there is no code in the timer_timer()? Will it just keep running?

    Thanks!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: What happens when a timer is enabled but..

    Yes, but you would never know it because there is nothing that would indicate it is actually running.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Wisconsin
    Posts
    788

    Re: What happens when a timer is enabled but..

    Does it take processor time? Does it keep a form open?

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: What happens when a timer is enabled but..

    The answer to both of those is probably, but each depends on exactly how the compiler is designed.

    Why does it matter? (surely if there is a timer with no code, there is no point having it at all)

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: What happens when a timer is enabled but..

    Quote Originally Posted by mojo69 View Post
    Does it take processor time? Does it keep a form open?
    If a timer is enabled and the interval is non-zero, then it is running. Taking up processor time? Sure, but very little and maybe only when the timer actually fires. Even though you don't have any code, the timer fires at its interval to the timer control. The timer control calls your timer event and runs the code, if any. FYI: VB timers are windowed controls, so they do take some system resources while they exist.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Wisconsin
    Posts
    788

    Re: What happens when a timer is enabled but..

    I found this in my code and it must have been copied somehow into the form. The interval was set to 64. I did not intend to have this timer be in the program. It is no longer there or used. My question comes from the fact that some pretty funny (actually not funny) things are going on with the form. I am wondering if the timer was firing, even without any code in it, could it cause anything to happen?

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: What happens when a timer is enabled but..

    As I mentioned, the timer will fire but it can't execute anything if you don't have any code in its event. We are talking about a VB timer control correct? Not some custom control?

    I don't know exactly how a VB timer works, but here is my guess based on what I do know about it.
    1. At runtime VB creates a window, this becomes the runtime timer
    2. VB then applies an API timer to that window via SetTimer
    3. The window receives WM_TIMER messages at the interval intended
    The above is what I know; the following is a guess
    4. VB implements an interface in your application that the timer window knows about
    5. When the timer window gets a WM_Timer message, it calls that interface
    6. That interface is your Timer_Timer event.
    This goes on forever until you disable the timer, set its interval to zero, or the application closes -- which closes the timer window which destroys the API timer.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Wisconsin
    Posts
    788

    Re: What happens when a timer is enabled but..

    This is a vb timer control.

    If the form performs an unload me does this end the timer?

    The application stays open but the user close the form.

    It sounds like if the timer is enabled that at least some action is being performed(Windows API), Am I correct to think that?

  9. #9
    PowerPoster CDRIVE's Avatar
    Join Date
    Jul 2007
    Posts
    2,620

    Re: What happens when a timer is enabled but..

    Quote Originally Posted by mojo69 View Post
    This is a vb timer control.

    If the form performs an unload me does this end the timer?

    The application stays open but the user close the form.

    It sounds like if the timer is enabled that at least some action is being performed(Windows API), Am I correct to think that?
    LaVolpe answered all of these questions in great detail. Did you read his last post??
    <--- Did someone help you? Please rate their post. The little green squares make us feel really smart!
    If topic has been resolved, please pull down the Thread Tools & mark it Resolved.


    Is VB consuming your life, and is that a bad thing??

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: What happens when a timer is enabled but..

    mojo69, I think you may be focusing on the wrong thing. A timer isn't going to prevent your forms from unloading or the app from closing, except in some rare cases, but especially not, if there is no code in the timer event.

    I suspect you already tried removing the timer from your project? If not, do so, and see if your problems continue. If they do continue, look at the FAQs section regarding closing your application
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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