From 26a99679a77ce61ba2bb976aae507b81b5a22ce4 Mon Sep 17 00:00:00 2001 From: Hylke Bons Date: Sun, 8 May 2011 20:35:26 +0100 Subject: [PATCH] controller: dispose the fetcher when we're done so it can be garbage collected --- SparkleLib/SparkleFetcher.cs | 12 ++++++++++-- SparkleShare/SparkleController.cs | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/SparkleLib/SparkleFetcher.cs b/SparkleLib/SparkleFetcher.cs index 859ee901..c3400371 100644 --- a/SparkleLib/SparkleFetcher.cs +++ b/SparkleLib/SparkleFetcher.cs @@ -35,6 +35,7 @@ namespace SparkleLib { private string target_folder; private string remote_url; + private Thread thread; public SparkleFetcher (string remote_url, string target_folder) @@ -55,7 +56,7 @@ namespace SparkleLib { if (Directory.Exists (this.target_folder)) Directory.Delete (this.target_folder, true); - Thread thread = new Thread (new ThreadStart (delegate { + this.thread = new Thread (new ThreadStart (delegate { if (Fetch ()) { SparkleHelpers.DebugInfo ("Fetcher", "[" + this.target_folder + "] Fetching finished"); @@ -69,7 +70,14 @@ namespace SparkleLib { } })); - thread.Start (); + this.thread.Start (); + } + + + public void Dispose () + { + this.thread.Abort (); + this.thread.Join (); } diff --git a/SparkleShare/SparkleController.cs b/SparkleShare/SparkleController.cs index 0e48ba3b..dd32d2e4 100644 --- a/SparkleShare/SparkleController.cs +++ b/SparkleShare/SparkleController.cs @@ -1007,6 +1007,8 @@ namespace SparkleShare { if (FolderListChanged != null) FolderListChanged (); + + fetcher.Dispose (); }; @@ -1023,6 +1025,8 @@ namespace SparkleShare { if (FolderFetchError != null) FolderFetchError (); + + fetcher.Dispose (); };