Solved

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

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

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…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

776 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