Only run next queued task if the previous was successful

This commit is contained in:
David Fowler 2016-10-01 03:29:49 -07:00
parent 5baaaac22d
commit f4f763f136
1 changed files with 9 additions and 1 deletions

View File

@ -41,7 +41,15 @@ namespace Microsoft.AspNetCore.Sockets
return _lastQueuedTask;
}
var newTask = _lastQueuedTask.ContinueWith((t, s1) => taskFunc(s1), state).Unwrap();
var newTask = _lastQueuedTask.ContinueWith((t, s1) =>
{
if (t.IsFaulted || t.IsCanceled)
{
return t;
}
return taskFunc(s1);
},
state).Unwrap();
_lastQueuedTask = newTask;
return newTask;
}