[IronPython] Timer constructor fails on float
dinov at microsoft.com
Sun Dec 20 11:31:18 PST 2009
There's no overload that takes a float - just overloads that take int, int64, and uint32 and TimeSpan objects. Because there are multiple numeric types we can't pick which one is better to call - we lose precision either way. I would recommend:
timer = System.Threading.Timer(_callback, None, int(100.1), 0) # Throws exception
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Idan Zaltzberg
Sent: Saturday, December 19, 2009 10:20 PM
To: users at lists.ironpython.com
Subject: [IronPython] Timer constructor fails on float
I recently encountered a problem when creating timers.
It seems that creating a timer with a floating point interval or delay throws an exception:
>>> def _callback(n): pass
>>> timer = System.Threading.Timer(_callback, None, 100, 0) # Works fine
>>> timer = System.Threading.Timer(_callback, None, 100.1, 0) # Throws exception
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: expected TimerCallback, got function
How can I solve this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Users