Solved

C# - How to set 2100 hours as a Timer.Interval ?

Posted on 2014-01-10
5
328 Views
Last Modified: 2014-02-24
Hello guys,

How to set 2100 hours + 1 minute as a Timer.Interval ? or int 7,560,000,000

But the Int32.MaxValue is 2,147,483,647!

In here says " The time, in milliseconds, between Elapsed events. The value must be greater than zero, and less than or equal to Int32.MaxValue".

Seriously, I need 2100 hours on a timer!

How to solve this problem?
0
Comment
Question by:ocaccy
  • 2
  • 2
5 Comments
 
LVL 11

Assisted Solution

by:MajorBigDeal
MajorBigDeal earned 167 total points
ID: 39772926
At the start record the time.  

Have a timer that elapsed every second.

Each time it elapsed, calculate the difference between the current time and the start time to see if the time has expired.

You could record the start time in a file and set it up to still work even if your server bounces in the meanwhile.
0
 
LVL 44

Assisted Solution

by:AndyAinscow
AndyAinscow earned 333 total points
ID: 39773019
How accurate must the +1 minute be ?

Note the current date/time and add 2100 hours + 1 minute and that is your target time.
(Consider storing this target eg in file or registry - reboot / crash....)
Set a timer going that fires each minute (or other interval as you prefer).  
In the timer event check the current time is still less than the target time.  If not then the time has elapsed
0
 

Author Comment

by:ocaccy
ID: 39773279
Hi,
I need this: ((2100  * 60  * 60  * 1000)+60000)

This app, is WinForm app.

This app has a loop 2100 hour + 1 minute.

 MajorBigDeal and  AndyAinscow,  could you explain with a example?

Thanks in advance, ocaccy.
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 333 total points
ID: 39773288
In the timer event (for my suggestion, the other is similar) some air code
if(now > target)
  {
    //stop timer
    //run the code you require when the time is reached
  }
0
 

Author Closing Comment

by:ocaccy
ID: 39884317
Thank you.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question