You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DownloadFileTaskAsync not throwing an OperationCanceledException when CancellationToken is canceled #203
When passing a CancellationToken to DownloadFileTaskAsync, I'm expecting the method to throw an OperationCanceledException if the cancellation has been requested and the download is cancelled.
This would allow me to manage the cancellation properly later in my code.
This does not seem to be the case today: this test should not fail:
Hi @Otiel — sorry for the late reply, I’ve been offline for a while due to recent issues in Iran.
In this library, cancellation is reported via the OnDownloadFileCompleted completion event (download complete callback). As noted in the documentation, errors and cancellations are surfaced there rather than by throwing from DownloadFileTaskAsync().
So when you cancel the CancellationToken, the download completes and the completion event will indicate cancellation (e.g. e.Cancelled == true). Please handle cancellation in that event handler.
Activity
bezzad commentedon Feb 8, 2026
Hi @Otiel — sorry for the late reply, I’ve been offline for a while due to recent issues in Iran.
In this library, cancellation is reported via the OnDownloadFileCompleted completion event (download complete callback). As noted in the documentation, errors and cancellations are surfaced there rather than by throwing from DownloadFileTaskAsync().
So when you cancel the CancellationToken, the download completes and the completion event will indicate cancellation (e.g. e.Cancelled == true). Please handle cancellation in that event handler.
Otiel commentedon Feb 8, 2026
Hi @bezzad, got it, thanks for the reply.
Good luck with the situation in your country, I hope you can stay safe. ❤️