I was wondering how good tasks are for scenarios where the main issue is resource locking (think COM port access, for example).
If my task is this :
Task
{
lock(resource)
{
resource.doSomething();
}
};
What it essentially does, is wait until the resource is free, and then use it.
My question is this : if the resource is locked, does the task go back to the task queue, or is the thread locked until the resource is free?
My understanding is that if the task is locked, in this scenario, it would be better to use a thread to avoid filling the thread pool with locked threads, is it right?