System.Windows.Forms.Timer

C

cronusf

The System.Windows.Forms.Timer interval is in milliseconds. Is it OK
to have a time trigger at long intervals like every 16 hours? Or is
there a better timer designed for longer intervals?
 
I

Ignacio Machin ( .NET/ C# MVP )

The System.Windows.Forms.Timer interval is in milliseconds.  Is it OK
to have a time trigger at long intervals like every 16 hours?  Or is
there a better timer designed for longer intervals?

Hi,

As long as the span in milisecond is in range of the numeric type used
in the property you are safe.

But I would consider creating a scheduled task for this case.

I'm not sure if you can create a scheduled task using WMI (there is
nothing for this in the framework). You should look into the archives
for how to do it
 
C

cronusf

A 16-hour interval should be "fine".  But, it is true that at that level  
of granularity, you may find that the Windows task-scheduling mechanisms  
suit your needs better.  That would involve starting a whole new process  
to execute the task, but doing that every 16-hours, the overhead of  
starting a new process should be completely insignificant.

Where did you get 16 hours from? I see that 1 week = 604 800 000
milliseconds, so I would set an interval to handle a week even. In
practice, I don't think a week would ever be schedule (a weekend is
more likely the max length). The issue is that the user can schedule
the time for an event to occur from one hour to one week.

Thanks for the input.
 
C

cronusf

Where did you get 16 hours from?
Um, your post?  You wrote: "Is it OK to have a time trigger at long  
intervals LIKE EVERY >>>16<<< HOURS" (emphasis mine).

Doh. Sorry, after lunch I forgot I specifically mention 16 hours,
even though that number I gave was not exactly the max length I was
looking for. Thanks for your additional info on the Windows task-
scheduling mechanism.
 

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

Top