It is dangerous to suspend a task other than yourself, unless you KNOW exactly what it is doing at the moment, as if it happens to be using some guarded resource, you have locked up that resource. So just because you removed the last client, the task may still be doing something for that client and perhaps as control of some system resource. You BLOCK on a specific thing, like a semaphore, a queue, a task notification, etc. That is what I was suggesting, setup something like a semaphore, that the task can block on when it has no work to do, and when someone adds work they can give that resource to unblock the task. You could also use the direct to task notification system as that semaphore to be a bit more efficient, the semaphore, being more explicit is sometimes clearer to someone first learning these interactions.
1 Like