diff --git a/SparkleLib/SparkleListenerBase.cs b/SparkleLib/SparkleListenerBase.cs index 2820f335..9f3c44ba 100755 --- a/SparkleLib/SparkleListenerBase.cs +++ b/SparkleLib/SparkleListenerBase.cs @@ -164,7 +164,10 @@ namespace SparkleLib { public virtual void Dispose () { - this.reconnect_timer.Dispose (); + if (this.reconnect_timer != null) { + this.reconnect_timer.Stop (); + this.reconnect_timer.Dispose (); + } } diff --git a/SparkleLib/SparkleListenerTcp.cs b/SparkleLib/SparkleListenerTcp.cs index 0a262f37..f022cbbe 100755 --- a/SparkleLib/SparkleListenerTcp.cs +++ b/SparkleLib/SparkleListenerTcp.cs @@ -237,12 +237,14 @@ namespace SparkleLib { public override void Dispose () { + if (this.socket != null) { + this.socket.Close (); + this.socket = null; + } + this.thread.Abort (); this.thread.Join (); - if (this.socket != null) - this.socket.Close (); - base.Dispose (); } diff --git a/SparkleLib/SparkleRepoBase.cs b/SparkleLib/SparkleRepoBase.cs index 7b3e8a81..5a82d3ba 100755 --- a/SparkleLib/SparkleRepoBase.cs +++ b/SparkleLib/SparkleRepoBase.cs @@ -619,6 +619,8 @@ namespace SparkleLib { this.listener.Disconnected -= ListenerDisconnectedDelegate; this.listener.AnnouncementReceived -= ListenerAnnouncementReceivedDelegate; + this.listener.Dispose (); + if (!UseCustomWatcher) this.watcher.Dispose (); }