Solved

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

Posted on 2014-01-10
5
323 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now