At times I need to terminate a task immediately without waiting for it to finish.
What would be the best approach to do so?
Hey Carlos,
One approach would be to set a global flag to indicate that you want the task to terminate.
Additionally, you can call the vTaskAbortDelay function on the task to end any blocking it is currently in.
1 Like
It almost NEVER is what you actually want, as “immediately” means, right now, without doing ANY cleanup.
Normally, you want to do as Colin suggests and set a flag to tell the task to stop want it is doing and clean up after itself.
Big point, tasks are NOT “Processes” that include “cleanup” when they are killed, but are all part of one big program that works together. The OS doesn’t isolate tasks from each other and track resources claimed by them.
2 Likes