In a C# .NET Core application, given
public Task<Thing> MyMethod(int i) { ... }
...
var MyTask = MyMethod(3);
Thing output;
try
{
output = await MyTask;
}
catch
{
var x = MyTask.Result;
throw;
}
If an exception is thrown while executing MyTask
, in the catch
block will MyTask.Result
be null
? Or will referencing it trigger another exception?
1