mrphil2105
mrphil2105
CC#
Created by mrphil2105 on 4/1/2023 in #help
❔ Upside Down?
I have this weird Discord bug where everything is upside down. Pls help thx.
7 replies
CC#
Created by mrphil2105 on 11/7/2022 in #help
Reporting download progress with IAsyncEnumerable
Is reporting progress with an IAsyncEnumerable<T> weird? I have the following:
public interface IDownloadService
{
IAsyncEnumerable<DownloadProgress> DownloadAsync(CancellationToken cancellationToken = default);
}
public interface IDownloadService
{
IAsyncEnumerable<DownloadProgress> DownloadAsync(CancellationToken cancellationToken = default);
}
Is this a weird thing to do? I know it will "pause" the download in-between each progress yield (that is yield return new DownloadProgress(...)). But I kind of like the way you consume it:
var enumerable = _downloadService.DownloadAsync(cancellationToken);

await foreach (var progress in enumerable.WithCancellation(cancellationToken))
{
// Use 'progress' here...
}
var enumerable = _downloadService.DownloadAsync(cancellationToken);

await foreach (var progress in enumerable.WithCancellation(cancellationToken))
{
// Use 'progress' here...
}
What are your thoughts?
5 replies