mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-21 22:05:38 -04:00
New: Rebuilt Completed/Failed download handling from scratch
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
|
||||
namespace NzbDrone.Common.TPL
|
||||
{
|
||||
public class Debouncer
|
||||
{
|
||||
private readonly Action _action;
|
||||
private readonly System.Timers.Timer _timer;
|
||||
|
||||
public Debouncer(Action action, TimeSpan debounceDuration)
|
||||
{
|
||||
_action = action;
|
||||
_timer = new System.Timers.Timer(debounceDuration.TotalMilliseconds);
|
||||
_timer.Elapsed += timer_Elapsed;
|
||||
}
|
||||
|
||||
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
_timer.Stop();
|
||||
_action();
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
_timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user