Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Input parameteres to DragOver 2 58
.NET Enums [Flags] & Bitwise Design Question 6 53
asp.net, radiobuttonlist, c# 3 69
async questions 5 49
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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