|
-
May 29th, 2009, 01:54 PM
#1
Thread Starter
Fanatic Member
[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!
-
May 29th, 2009, 01:54 PM
#2
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.
-
May 29th, 2009, 02:01 PM
#3
Thread Starter
Fanatic Member
Re: What happens when a timer is enabled but..
Does it take processor time? Does it keep a form open?
-
May 29th, 2009, 02:11 PM
#4
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)
-
May 29th, 2009, 02:14 PM
#5
Re: What happens when a timer is enabled but..
 Originally Posted by mojo69
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.
-
May 29th, 2009, 02:18 PM
#6
Thread Starter
Fanatic Member
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?
-
May 29th, 2009, 03:14 PM
#7
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.
-
May 29th, 2009, 03:17 PM
#8
Thread Starter
Fanatic Member
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?
-
May 29th, 2009, 04:18 PM
#9
Re: What happens when a timer is enabled but..
 Originally Posted by mojo69
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?? 
-
May 29th, 2009, 05:25 PM
#10
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|