Reading through the answers to this question made me think about what happens with exceptions when the expected task is thrown. Do all "clients" get an exception? I admit that I can mislead a couple of things here; that is the reason I'm asking for clarification.
I will tell you a specific scenario ... Let's say I have a server with a global collection of long Task instances launched by clients. After starting one or more tasks, the client can request their progress and get results when they become available, as well as any errors that may occur.
Tasks themselves can perform very different business-specific things - as a rule, there are no two identical. However, if one of the clients tries to run the same task as the previous one, the server should recognize this and βattachβ the second client to the existing task instead of wrapping a new copy.
Now, every time when any client requests the status of a task of interest to him, he performs something in this direction:
var timeout = Task.Delay(numberOfSecondsUntilClientsPatienceRunsOut); try { var result = await Task.WhenAny(timeout, task); if (result == timeout) {
In short, this gives the task some reasonable time to finish what he is doing at the beginning, and then returns to the message of ongoing progress. This means that there is a potentially significant window of time during which several clients can observe the same task.
My question is: if during this window a challenge arises to challenge, is the observed (and handled) exception for all clients?
aoven source share