Похожие чаты

Task.WhenAll Will this return error when one of the task returns

error ?
Or it will be successful even if I task got success

6 ответов

17 просмотров

https://stackoverflow.com/questions/39589640/ignore-the-tasks-throwing-exceptions-at-task-whenall-and-get-only-the-completed

Say you have two tasks given to Task.WhenAll. One will throw an exception and the other will complete successfully. When used with Task.WhenAll, you'll finally get AggregateException thrown that wraps the exception of the first task. The second task will still complete and the AggregateException is thrown after the second succeeds.

you know you can press F1 on a method to go to the official documentation, rigth?

Athul-N Автор вопроса
luca flan di vedure
you know you can press F1 on a method to go to the...

I know I checked It doesn’t says it will throw any exception when the task gets failed

Athul N
I know I checked It doesn’t says it will throw any...

remarks section say > The returned task will always end in the RanToCompletion state with its Result set to the first task to complete. This is true even if the first task to complete ended in the Canceled or Faulted state. whenany returns the first task that completed, simply also im not bashing, but simply writing a test is literally shorter than the question you asked var test = await Task.WhenAny(Task.FromException(new Exception()), Task.Delay(1));

Athul-N Автор вопроса

Ok 👍

Похожие вопросы

Обсуждают сегодня

Карта сайта