From e8a6405fea369d084a0d378ec6c273c07ac33957 Mon Sep 17 00:00:00 2001 From: Thierry Matthey Date: Mon, 6 May 2024 14:57:06 +0200 Subject: [PATCH] Try catch for blocking recieve which can throw --- src/NetMQ/Core/Mailbox.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/NetMQ/Core/Mailbox.cs b/src/NetMQ/Core/Mailbox.cs index b23c6469a..dc10b3781 100644 --- a/src/NetMQ/Core/Mailbox.cs +++ b/src/NetMQ/Core/Mailbox.cs @@ -19,6 +19,7 @@ You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . */ +using System; using System.Diagnostics; using System.Net.Sockets; using NetMQ.Core.Utils; @@ -208,8 +209,17 @@ public bool TryRecv(int timeout, out Command command) return true; // If there are no more commands available, switch into passive state. - m_active = false; - m_signaler.Recv(); + try + { + m_active = false; + m_signaler.Recv(); + } + catch + { + m_active = true; + command = default(Command); + return false; + } } // Wait for signal from the command sender.