System.Timers.Timer

  • Thread starter Thread starter Jonathan Woods
  • Start date Start date
J

Jonathan Woods

Hi there,

I have three methods these need to execute at every interval time. I
would like to know which option is better?

Option A)
Three System.Timers.Timer objects these execute each method.

timer1.Elapsed += new
System.Timers.ElapsedEventHandler(Method1_Elapsed);
timer2.Elapsed += new
System.Timers.ElapsedEventHandler(Method2_Elapsed);
timer3.Elapsed += new
System.Timers.ElapsedEventHandler(Method3_Elapsed);

Option B)
One System.Timers.Timer object that execute all methods.
timer1.Elapsed += new
System.Timers.ElapsedEventHandler(Method1_Elapsed);
timer1.Elapsed += new
System.Timers.ElapsedEventHandler(Method2_Elapsed);
timer1.Elapsed += new
System.Timers.ElapsedEventHandler(Method3_Elapsed);
 
Jonathan Woods said:
I have three methods these need to execute at every interval time. I
would like to know which option is better?

Do you want the methods to execute in parallel, or in series? If you
don't mind them executing in series, I'd use the second version.
 

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