title: C# Azure Service Bus Queue OnMessage Callback
body: <p>I'm writing some functionality that responds to an Azure Service Bus Queue. This currently polls on a specified queue and OnMessage triggers a callback to a method in the original class that calls it:</p>
  
  <pre><code>    partial class Class1
      {
           private void BeginProcessing()
           {
               serviceBusHelper.Listen(QueueType.Inbound, HandleTransaction);
           }
           private bool HandleTransaction(BrokeredMessage message)
           {
               ...    
           }
      }
  </code></pre>
  
  <p>And then the service bus helper class:</p>
  
  <pre><code>public class ServiceBusHelper : IServiceBusHelper
  {
      ManualResetEvent CompletedResetEvent = new ManualResetEvent(false);
  
      public void Listen(QueueType queue, Action&lt;BrokeredMessage&gt; callback)
      {
  
          switch (queue)
          {
              case QueueType.Inbound:
                  inboundClient.OnMessage(message =&gt;
                  {
                      try
                      {
                          callback(message);
                      }
                      catch (Exception ex)
                      {
                          ...
                      }
                      CompletedResetEvent.WaitOne();
                  });
                  break;
              ...
          }
  }
  </code></pre>
  
  <p>It is connecting correctly to the azure service bus queue and retrieving the message, however the callback never seems to actually trigger. What I'm trying to achieve is a service that will continuously respond to an OnMessage event, trigger a new worker (from within class1) despite the OnMessage actually being triggered from the ServiceBusHelper class.</p>