Search code examples
omnet++veins

how to cancel a timer when using timerManager in veins omnet


I'm using TimerManager class provided in veins to manage timers in my simulation. I created a recurring timer that fires every 5 seconds and I want to cancel it when a specific msg is received but I don't know how to use the cancel method:

void cancel(TimerHandle handle)

I don't understand what is TimerHandle and what parameter should I pass to the method in order to cancel the timer

PS:i want to cancel a specific timer not the TimerManager instance


Solution

  • When creating a timer, TimerManager::create returns a TimerHandle. You can use this to cancel the timer by passing it to TimerManager::cancel.