I have a long running unsafe background task that may need to be canceled in the middle of its operation while processing may objects. There is no need to roll back any transactions, I just want to stop the task.
My first thought was to continually monitor the VAF configuration for the task and check if its "enabled" status was changed to "disabled" and then stop processing. This works, but its also updating the progress of the task using job.Update and when the VAF configuration is saved while the task is running, a call to job.Update will throw the exception
- $exception {"Exception of type 'MFiles.VAF.AppTasks.AppTaskException' was thrown."} MFiles.VAF.AppTasks.AppTaskException
I also have notice that the property job.IsTaskCancellationRequested is now set to true.
My question is what is the recommended way to cancel out of the long running task?
Thanks,
Scott