listener: When disposing, close socket before killing thread. Fixes #1601

This commit is contained in:
Hylke Bons 2015-01-13 22:18:47 +00:00
parent 2679235bb7
commit 6d5f23cb19
3 changed files with 11 additions and 4 deletions

View file

@ -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 ();
}
}

View file

@ -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 ();
}

View file

@ -619,6 +619,8 @@ namespace SparkleLib {
this.listener.Disconnected -= ListenerDisconnectedDelegate;
this.listener.AnnouncementReceived -= ListenerAnnouncementReceivedDelegate;
this.listener.Dispose ();
if (!UseCustomWatcher)
this.watcher.Dispose ();
}