From: Matthew Endsley Date: Tue, 2 Feb 2021 15:07:52 +0000 (-0800) Subject: Only join threads if we were active X-Git-Tag: 1.0.0~20^2~16 X-Git-Url: https://git.deb.at/?a=commitdiff_plain;h=ea213a32c35d7498f4711f689b61dc777715a925;p=rhonda%2Fimpostor.hazel.git Only join threads if we were active --- diff --git a/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs b/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs index 7e2da60..98f8301 100644 --- a/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs +++ b/Hazel/FewerThreads/ThreadLimitedUdpConnectionListener.cs @@ -359,15 +359,19 @@ namespace Hazel.Udp.FewerThreads try { this.socket.Close(); } catch { } try { this.socket.Dispose(); } catch { } + bool wasActive = this.isActive; this.isActive = false; this.receiveQueue?.CompleteAdding(); this.sendQueue?.CompleteAdding(); - this.reliablePacketThread.Join(); - this.sendThread.Join(); - this.receiveThread.Join(); - this.processThreads.Join(); + if (wasActive) + { + this.reliablePacketThread.Join(); + this.sendThread.Join(); + this.receiveThread.Join(); + this.processThreads.Join(); + } this.receiveQueue?.Dispose(); this.receiveQueue = null;