.NETGURU
system.timers.timer for very large intervals
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Peter Maco (VIP)
I created system.timers.timer for very long interval from TimeSpan.MaxValue:

myTimer = new System.Timers.Timer(TimeSpan.MaxValue.TotalMilliseconds)

After calling Enable = true I have a ArgumentOutOfRangeException exception.
I found out that timer internally uses System.Threading.Timer object and uses
constructor with "int" for dueTime. I suppose it explicitly converts double
to int without checking for overflow and System.Threading.Timer is created
with negative number for dueTime which throws an exception.
Is it a bug ?
Reply to this message...
 
    
Robert Jordan
Peter Maco wrote:

[Original message clipped]

No. The argument is obviously out of range, so what? ;-)

bye
Rob
Reply to this message...
 
    
Peter Maco (VIP)
Out of range ??? There is no range in documentation and no
ArgumentOutOfRangeException exception expected (in documentation). So I
consider it as bug.

"Robert Jordan" wrote:

[Original message clipped]

Reply to this message...
 
    
Robert Jordan
Peter Maco wrote:

[Original message clipped]

myTimer = new System.Timers.Timer(TimeSpan.MaxValue.TotalMilliseconds)

TimeSpan.MaxValue is equivalent to 9,223,372,036,854,775,807,
And this IS out of every range I can think about.

bye
Rob

[Original message clipped]

Reply to this message...
 
    
Girish bharadwaj
System.Timers.Timer takes a Double. I set it to Double.MaxValue with no
exceptions.
What version of .NET framework are you using?

--
Girish Bharadwaj
http://msmvps.com/gbvb
"Robert Jordan" <Click here to reveal e-mail address> wrote in message
news:ci4krk$d65$06$Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Daniel Carlsson
Considering the documentation doesnt mention any
ArgumentOutOfRangeExceptions Id say its a bug yes.
If you really need to wait for a very long time before doing something you
should probably use a thread instead, which could contain an DateTime with
the time it should call a function.

"Peter Maco" <Peter Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
> I created system.timers.timer for very long interval from
TimeSpan.MaxValue:
[Original message clipped]

Reply to this message...
 
    
Willy Denoyette [MVP] (VIP)
"Peter Maco" <Peter Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

I would say this is a "documentation" bug.
The System.Timers.Timer takes a double as argument, but the value must be 0
=> interval <= Int32.MaxValue, or -1.
The same goes for System.Threading.Timer which takes an int or a long as
interval, but again the value of the interval is restricted to Int32.MaxVal.
This is because the underlying OS WaitableTimer object uses a long (signed
32 bit in C) for the period of the timer.

Willy.

Reply to this message...
 
 
System.ArgumentOutOfRangeException
System.DateTime
System.Double
System.Int32
System.Threading.Timer
System.Timers.Timer
System.TimeSpan




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification