How to manually start/stop jobs
amyrprv opened this issue · 1 comments
How I can have control over jobs and manually start/stop themes?
I utilize the Service and make an API endpoint so that the front end can trigger the process defined in my Service class. I haven't tried to stop the process when it is running. But you probably can try to pass a cancellation token to the process.
The service I referred to is like the one below.
ServiceWorkerCronJob/ServiceWorkerCronJobDemo/Services/MyCronJob2.cs
Lines 30 to 32 in 6993865
In the CronJob class, you call the service to do work. You can do the same thing in your controller, and you don't need to initiate a scope in the controller. Then admins can click a button in a web page to run the job on demand.