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
string [] Folders = Directory.GetDirectories (FoldersPath);
Repositories = new Repository [Folders.Length];
AutoFetcher AutoFetcher = new AutoFetcher (Repositories);
int i = 0;
foreach (string Folder in Folders) {
@ -122,6 +122,8 @@ public class SparklePonyUI {
i++;
}
AutoFetcher AutoFetcher = new AutoFetcher (Repositories);
if (!HideUI) {
// 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
Timer.Interval = 5000;
Timer.Elapsed += delegate (object o, ElapsedEventArgs args) {
Interval = 5000;
Elapsed += delegate (object o, ElapsedEventArgs args) {
foreach (Repository Repository in Repositories) {
Timer.Stop ();
Stop ();
if (!Repository.MonitorOnly)
Repository.Fetch ();
Timer.Start ();
Start ();
}
};
Timer.Start();
}
public void StartTimer () {
Timer.Start ();
}
Start();
public void StopTimer () {
Timer.Stop ();
}
public bool isRunning () {
return Timer.Enabled;
}
}