Version 1.2.0

This commit is contained in:
Junior 2024-01-04 22:59:30 -03:00
parent 9b3a0e00a2
commit e74d93fab9
83 changed files with 110087 additions and 47507 deletions

View file

@ -1,40 +0,0 @@
namespace RHLauncher.RHLauncher
{
public class ProgressThrottler : IProgress<ProgressReport>
{
private readonly IProgress<ProgressReport> _progress;
private readonly int _intervalMs;
private readonly TaskScheduler _scheduler;
private readonly object _lock = new();
private bool _isScheduled = false;
private ProgressReport? _latestReport;
public ProgressThrottler(IProgress<ProgressReport> progress, int intervalMs)
{
_progress = progress;
_intervalMs = intervalMs;
_scheduler = TaskScheduler.FromCurrentSynchronizationContext();
}
public void Report(ProgressReport value)
{
lock (_lock)
{
_latestReport = value;
if (!_isScheduled)
{
_isScheduled = true;
Task.Delay(_intervalMs, _latestReport.CancellationToken).ContinueWith(_ =>
{
lock (_lock)
{
_progress.Report(_latestReport);
_isScheduled = false;
}
}, _latestReport.CancellationToken, TaskContinuationOptions.ExecuteSynchronously, _scheduler);
}
}
}
}
}