mac: dispose watcher thread on quit

This commit is contained in:
Hylke Bons 2011-06-03 13:41:52 +01:00
parent 4d972c66d1
commit 2b0f53e1f3
2 changed files with 18 additions and 3 deletions

View file

@ -145,5 +145,12 @@ namespace SparkleShare {
return html; return html;
} }
} }
new public void Quit ()
{
this.watcher.Dispose ();
base.Quit ();
}
} }
} }

View file

@ -29,11 +29,12 @@ namespace SparkleShare {
public event ChangedEventHandler Changed; public event ChangedEventHandler Changed;
private DirectoryInfo last_changed; private DirectoryInfo last_changed;
private Thread thread;
public SparkleMacWatcher (string path) public SparkleMacWatcher (string path)
{ {
Thread thread = new Thread (new ThreadStart (delegate { this.thread = new Thread (new ThreadStart (delegate {
DateTime timestamp; DateTime timestamp;
DirectoryInfo parent = new DirectoryInfo (path); DirectoryInfo parent = new DirectoryInfo (path);
this.last_changed = new DirectoryInfo (path); this.last_changed = new DirectoryInfo (path);
@ -49,11 +50,11 @@ namespace SparkleShare {
Changed (relative_path); Changed (relative_path);
} }
Thread.Sleep (5000); Thread.Sleep (2500);
} }
})); }));
thread.Start (); this.thread.Start ();
} }
@ -74,5 +75,12 @@ namespace SparkleShare {
} catch (Exception) { } } catch (Exception) { }
} }
public void Dispose ()
{
this.thread.Join ();
this.thread.Abort ();
}
} }
} }