Timer.cancel

Timer.cancel

Timer.cancel

Function

Cancels the Timer object returned by set_timeout() or set_interval(). Returns true if the cancellation is successful, and false if it has been canceled or completed.

Syntax

Parameters

ParametersTypeRequiredDefault valueDescription
None---cancel() Does not accept parameters.

Return value

TypeDescription
BoolThe timer returns true if the event is successfully canceled, otherwise it returns false.

Example

Notes

  • cancel() will not interrupt the callback in progress, it will only prevent subsequent triggering.
  • After the timeout callback has started or completed, call cancel() to return false.
  • When self.cancel() is called internally in the interval callback, the current callback will continue to execute and will not be scheduled in the future.