How can I gracefully cancel or timeout a Haxe Timer when an operation takes too long?
0 reputation · 03 Dec 2025, 10:16 UTC
I’m using haxe.Timer.delay to schedule a function that performs a network request. If the request takes longer than expected, I’d like to cancel the timer and handle a timeout gracefully. I also need to cancel any pending timers when a new request is issued to avoid overlapping calls.
What is the idiomatic way to cancel a Timer before it fires? How can I add a timeout that triggers if the scheduled function hasn’t completed within a specified period? Finally, how can I ensure that Timer.stop is invoked even if the scheduled function throws an exception?