diff --git a/src/NetMQ/Core/Mailbox.cs b/src/NetMQ/Core/Mailbox.cs index b23c6469..dc10b378 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.