Why would a timer trigger when a form is shown?

UncleRonin

Well-known member
Joined
Feb 28, 2006
Messages
230
Location
South Africa
Programming Experience
5-10
I have come across something very strange. I have an MDI app with a bunch of children. On one particular form I have a timer which triggers every minute. For some reason, whenever I swop back to this form (I never close any of these forms so they are always running) the timer triggers! What the hell! It doesn't matter what interval or what order I do things, the minute the form is made visible it triggers the timer. What possible reasons could there be for this?

EDIT: Okay, I have found out that this only happens if in the Designer the timer's Enabled property is set to True. If it isn't and is enabled in the load method instead then this issue goes away. Weird. i dunno about anyone else but do you also find that sometimes you have to rebuild your entire project in order to force VS to compile changes that you have made?
 
UncleRonin
i dunno about anyone else but do you also find that sometimes you have to rebuild your entire project in order to force VS to compile changes that you have made?

NO, but if your project doesn't compile for any reason and you force it to run it will run with the last known good compilation. In other words, if you add somthing to your project that is wrong and neglect it forcing the project to run then you are running the project prior to the update with the error.

I may have confused you more with that or I just may have told you somthing you already knew but hopefully that helps.

As far as the timer being triggered when you get focus it has to do somthing with the code and or when you are enabling the timer. Even if you set the timer enabled property True or False it shouldn't fire just b/c you give it focus. You would have to post you code for myself and others to review it.
 
Back
Top