controller: dispose the fetcher when we're done so it can be garbage collected
This commit is contained in:
parent
825ea5b200
commit
26a99679a7
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1007,6 +1007,8 @@ namespace SparkleShare {
|
|||
|
||||
if (FolderListChanged != null)
|
||||
FolderListChanged ();
|
||||
|
||||
fetcher.Dispose ();
|
||||
};
|
||||
|
||||
|
||||
|
@ -1023,6 +1025,8 @@ namespace SparkleShare {
|
|||
|
||||
if (FolderFetchError != null)
|
||||
FolderFetchError ();
|
||||
|
||||
fetcher.Dispose ();
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue