1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-08-16 05:31:43 +02:00
Files
BackupEssentials
Backup
Controls
Data
Pages
Properties
Resources
Sys
Utils
Collections
IO
NativeMethods.cs
NumberSerialization.cs
Profiler.cs
ProgramArgsParser.cs
ScheduledUpdate.cs
WindowsVersion.cs
WpfExtensions.cs
App.xaml
App.xaml.cs
AppPageManager.cs
BackupEssentials.csproj
BackupReportWindow.xaml
BackupReportWindow.xaml.cs
BackupWindow.xaml
BackupWindow.xaml.cs
MainWindow.xaml
MainWindow.xaml.cs
TestingWindow.xaml
TestingWindow.xaml.cs
.gitignore
BackupEssentials.sln
LICENSE
README.md
2015-04-05 13:02:57 +02:00

30 lines
773 B
C#

using System;
using System.Windows.Threading;
namespace BackupEssentials.Utils{
class ScheduledUpdate{
public static ScheduledUpdate Forever(int seconds, Action update){
return new ScheduledUpdate(seconds,update);
}
public bool NeedsUpdate = false;
private readonly DispatcherTimer timer;
private ScheduledUpdate(int seconds, Action update){
timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0,0,seconds);
timer.Tick += (sender, args) => {
if (NeedsUpdate){
NeedsUpdate = false;
update();
}
};
}
public void Start(){
timer.Start();
}
}
}