Solved

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

Posted on 2014-01-10
5
334 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

636 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