#Schedule a task

1 messages · Page 1 of 1 (latest)

warped ruin
#

I want to schedule some code to run but than i could reset the timer (or at least cancel the schedule and start a new one), I heard TimerTask isn't really recommended to use so what should I use?

steep sphinxBOT
#

<@&1008423204219531294> please have a look, thanks.

steep sphinxBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

warped ruin
#

i prefer not to schedule to a specific time but to an amount of time in the future (for example: 5 minutes)

warped ruin
#

or is there another way?

torpid socket
#

You could have a look at kotlinx coroutines and the delay function

outer river
outer river
#

so just in memory

#

yeah - use a scheduled executor and keep track of the futures to cancel them

#

is it one time in the future or always a recurring thing?

outer river
#

yeah this is the secret sauce

#

you just need to store the scheduled futures somewhere to be able to cancel them

warped ruin
#

ok thank you