Page 1 of 1

Old Taskscheduler still runs after auto reloading extensions

Posted: 24 Sep 2019, 09:13
by marsoups
Hi,

I have a question about the task scheduler (sfs.getTaskScheduler()). I have noticed that if I have some scheduled tasks running, and frequently have extensions reload (to smoothly update the software without requiring a restart), or during development, that sometimes some of the old tasks are still running in the background, and this adds up over time so I have a situation where I can see schedules are running multiple times.

Is there a way to safely shut down and end a task (in the old "instance") when the extension is reloaded during an update situation ?

Many thanks for your help!

Re: Old Taskscheduler still runs after auto reloading extensions

Posted: 24 Sep 2019, 14:47
by Lapo
Hi,
are we talking about SFS2X? I ask because this was posted under SFS 1.x...

Thanks

Re: Old Taskscheduler still runs after auto reloading extensions

Posted: 25 Sep 2019, 06:47
by marsoups
Hi, yes my apologies. Are you able to move this thread?

Re: Old Taskscheduler still runs after auto reloading extensions

Posted: 25 Sep 2019, 07:12
by Lapo
marsoups wrote:Hi, yes my apologies. Are you able to move this thread?

Sure, done :)

Back to your question, you just need to keep a reference to every task that was added to the Scheduler, so that you can cancel them in your Extension's destroy() method.

Take a look here for an example:
https://smartfoxserver.com/blog/how-to- ... extension/

Hope it helps