Given the following snippet:
public Task StartReading()
{
var activityCheck = Task.Factory.StartNew(async () => await this.CheckActivityTimeout(), this._token.Token).Unwrap();
var reading = Task.Factory.StartNew(async () => await this.ReadAsync(), this._token.Token).Unwrap();
// for reference, this code produces the same result:
// var activityCheck = this.CheckActivityTimeout();
// var reading = this.ReadAsync();
return Task.WhenAny(reading, activityCheck);
}
When an exception is thrown in CheckActivityTimeout, I am catching it as follows.
var read = StartReading()
var tasks = new Task[] { read, taskx, tasky, taskz };
int completed = Task.WaitAny(tasks);
var r = tasks[completed];
r does not have it's exception set. Instead, if I look at the debugger, I find that the task r has the exception stored within a Result property. How do I get to this actual result?
r has type Id = 17, Status = RanToCompletion, Method = "{null}", Result = "System.Threading.Tasks.UnwrapPromise``1[System.Threading.Tasks.TaskExtensions+VoidResult]"
You can see that the actual exception is inside the result of the inner task. How do I propogate it upwards?
r.Exception == null
r.Result is inaccessible.
update
var r = Task.WhenAny(tasks).Result; // produces exactly the same wrapped result!
In the debugger it looks like this:

Task.Factory.StartNewdoes not supportasyncdelegates. UseTask.Runinstead.CheckActivityTimeout? why not calling them directly?Task.Runhas the same result.