/// <summary>
 /// Terminates this message queue. Once the queue is terminated, no further messages are delivered.
 /// But as this method runs asynchronously to the message delivery thread, it is possible that a message is still being
 /// delivered when this method returns.
 /// </summary>
 /// <remarks>
 /// This method requests its internal lock, so it must not be called while holding other locks, according to the
 /// MP2 multithreading guidelines.
 /// </remarks>
 public void Terminate()
 {
     if (_shutdownWatcher != null)
     {
         _shutdownWatcher.Remove();
     }
     _shutdownWatcher = null;
     UnregisterFromAllMessageChannels();
     _terminatedEvent.Set();
 }
 /// <summary>
 /// Terminates this message queue. Once the queue is terminated, no further messages are delivered.
 /// But as this method runs asynchronously to the message delivery thread, it is possible that a message is still being
 /// delivered when this method returns.
 /// </summary>
 /// <remarks>
 /// This method requests its internal lock, so it must not be called while holding other locks, according to the
 /// MP2 multithreading guidelines.
 /// A message queue which was terminated by this method may be restarted by calling <see cref="Start"/> again.
 /// </remarks>
 public void Terminate()
 {
     if (_shutdownWatcher != null)
     {
         _shutdownWatcher.Remove();
     }
     _shutdownWatcher = null;
     UnregisterFromAllMessageChannels();
     if (!_terminatedEvent.SafeWaitHandle.IsClosed)
     {
         _terminatedEvent.Set();
     }
 }