Timers

  • Thread starter Thread starter cameljs18
  • Start date Start date
C

cameljs18

How can i get a timer to start running as soon as the windows
application is started
 
How can i get a timer to start running as soon as the windows
application is started

What kind of timer? Are you trying to measure time? Or have something
happen after some period of time? Where do you want it to run? Inside
the application? As an external process?

You can instantiate and start a Stopwatch instance in your program's
Main() method. Any time you want to know how long it's been since the
application started, just look at the Stopwatch.Elapsed property.

If you want something else, you should probably think about writing a
question that's more specific and which describes your need without
ambiguity.

Pete
 
What kind of timer? Are you trying to measure time? Or have something
happen after some period of time? Where do you want it to run? Inside
the application? As an external process?

You can instantiate and start a Stopwatch instance in your program's
Main() method. Any time you want to know how long it's been since the
application started, just look at the Stopwatch.Elapsed property.

If you want something else, you should probably think about writing a
question that's more specific and which describes your need without
ambiguity.

Pete

Sorry wrote in a hurry.I have two windows forms and i need to access
the tick_event of a timer in first form from the second.Is there a way
i can do this,I want it so that everytime the timer ticks in the first
form it runs a method in the other form.I dont want to create a
instance of the second form in the first form tho.
 
Sorry wrote in a hurry.I have two windows forms and i need to access
the tick_event of a timer in first form from the second.Is there a way
i can do this,I want it so that everytime the timer ticks in the first
form it runs a method in the other form.I dont want to create a
instance of the second form in the first form tho.

I have found out how thnks for the help
 
So how did you do it? Personally, I would create a singleton instance
of a timer in your code (which is populated when the first form opens) and
then have all of your other forms subscribe to that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top