DSL reschedule anonymous timer

Hello,

I need to reschedule a timer, but since it’s used in a Procedure, it would be more confortable to declare it anonymously, like this:

createTimer(now, [ |
   if (some_condition) {
      reschedule(now.plusSeconds(1))
   } else {
      do_something()
  }
])

Obviously the above code fails on the reschedule(now.plusSeconds(1)) statement. Is there any way to achieve this?

Thanks.

No. You have to tell it what to reschedule, somehow.

The usual trick where there may be a number of similar timers is to store the handles in a ‘global’ Map,indexed by related Item name or similar.
Example-

I ended up using a List to reference all the timers inside the Procedure.