update AutoFetcher class

This commit is contained in:
Hylke Bons 2010-04-27 22:10:53 +01:00
parent 94b356dddb
commit 62e9484014

View file

@ -114,7 +114,7 @@ public class SparklePonyUI {
// Get all the folders in ~/Collaboration // Get all the folders in ~/Collaboration
string [] Folders = Directory.GetDirectories (FoldersPath); string [] Folders = Directory.GetDirectories (FoldersPath);
Repositories = new Repository [Folders.Length]; Repositories = new Repository [Folders.Length];
AutoFetcher AutoFetcher = new AutoFetcher (Repositories);
int i = 0; int i = 0;
foreach (string Folder in Folders) { foreach (string Folder in Folders) {
@ -122,6 +122,8 @@ public class SparklePonyUI {
i++; i++;
} }
AutoFetcher AutoFetcher = new AutoFetcher (Repositories);
if (!HideUI) { if (!HideUI) {
// Create the window // Create the window
@ -162,35 +164,23 @@ public class SparklePonyStatusIcon : StatusIcon {
} }
public class AutoFetcher { public class AutoFetcher : Timer {
private Timer Timer; public AutoFetcher (Repository [] Repositories) : base () {
public AutoFetcher (Repository [] Repositories) {
Timer = new Timer();
// Fetch changes every 30 seconds // Fetch changes every 30 seconds
Timer.Interval = 5000; Interval = 5000;
Timer.Elapsed += delegate (object o, ElapsedEventArgs args) { Elapsed += delegate (object o, ElapsedEventArgs args) {
foreach (Repository Repository in Repositories) { foreach (Repository Repository in Repositories) {
Timer.Stop (); Stop ();
if (!Repository.MonitorOnly) if (!Repository.MonitorOnly)
Repository.Fetch (); Repository.Fetch ();
Timer.Start (); Start ();
} }
}; };
Timer.Start();
}
public void StartTimer () { Start();
Timer.Start ();
}
public void StopTimer () {
Timer.Stop ();
}
public bool isRunning () {
return Timer.Enabled;
} }
} }