9 years, 7 months ago.

Why would you need to detach Timeout

If I understand correctly, Timeouts call the interrupt only once after the specified time. If so, then why would you need to detach it? Is it bad if I don't detach it?

If the interrupt is called continuously after the time period, what makes it different from Ticker?

Thanks

Question relating to:

1 Answer

9 years, 7 months ago.

You would normally only do so if you needed to stop the interrupt before it happens.

e.g. If you wanted to put the system to sleep after 30 seconds of idle time then the easiest way is to set a timeout for 30 seconds that then calls your sleep code. If something then happens before the 30 seconds are up you would detach the Timeout.

Accepted Answer

Thanks. Is there any reason to detach the timeout after it's been used, in order to reuse it?

posted by Ethan P 04 Sep 2014

No, reason to do that. You can re-use it without detaching first. You can re-use it without detaching even if it hasn't triggered yet, the only time you need to detach is if you want to stop the timeout and not replace it with a new one.

posted by Andy A 05 Sep 2014