OF-DL/OF DL.Gui/Services/AvaloniaProgressReporter.cs

22 lines
481 B
C#

using OF_DL.Services;
namespace OF_DL.Gui.Services;
internal sealed class AvaloniaProgressReporter(
Action<long> reportAction,
Func<bool> isCancellationRequested) : IProgressReporter
{
public void ReportProgress(long increment)
{
if (isCancellationRequested())
{
throw new OperationCanceledException("Operation canceled by user.");
}
if (increment > 0)
{
reportAction(increment);
}
}
}