Skip to content

Commit

Permalink
Updates: catch Exception at async enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
Leksiqq committed Mar 25, 2022
1 parent 5d6a6ef commit af28cd1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Library/PartialLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,10 @@ private void PrepareToExecute()

_loadTask = Task.Run(async () =>
{
await foreach (T item in _dataProvider!.ConfigureAwait(false))
await foreach (
T item in _dataProvider!
.ConfigureAwait(false)
)
{
if (_cancellationTokenSource.Token.IsCancellationRequested)
{
Expand All @@ -605,9 +608,13 @@ private void PrepareToExecute()
_queue.Enqueue(item);
_manualReset.Set();
}
}).ContinueWith(_ =>
}).ContinueWith(t =>
{
_manualReset.Set();
if (t.IsFaulted)
{
throw t.Exception;
}
});
}

Expand Down

0 comments on commit af28cd1

Please sign in to comment.