Why is this exception not caught?
You're just printing out the task
- which won't even have completed yet.
Printing out the task doesn't wait for it to complete, or try to fetch the value.
If you change your code to:
try
{
task.Wait();
}
... then I'd expect it to catch the exception.
(I was previously using Task<T>.Result
, but I notice this is a task with no return value, so it would just be the non-generic Task
.)