title: Event handler not firing on class method
body: <p>I have an event handler in a class which doesnt seem to trigger. I wonder if anyone had any ideas on why this may be happening (or not happening as is the case).</p>
  
  <p>The class inherits from another class and basically listens for messages from a message queue. When a message hits the queue the method onMessage() is called.</p>
  
  <p>From my (winforms, c#, .net 3.5) UI form, I'm trying to get the received message(s) back to the UI.</p>
  
  <p>If I call the method onMessage() manually from the instance on my form, the eventhandler does trigger correctly and passMessage is executed on my UI form.</p>
  
  <p>But when I receive a message thats come automated from the queue I'm listening on, the event handler is not triggered. I dont ever call the onMessage() method, that happens automatically.</p>
  
  <p>Does anyone have any ideas why the event handler is not triggering when onMessage() is called everytime I receive a message?</p>
  
  <p>Thanks</p>
  
  <p>UI:</p>
  
  <pre><code>private void btnConnect(object sender, EventArgs e)
  {
      MessageQueue myMQ = new MessageQueue();
      myMQ.Connect(...);
      //Register handler
          myMQ.MsgTrigger += new EventHandler(passMessage);
  }
  
  public void passMessage(object s, EventArgs e)
  {
      Console.WriteLine(s.ToString()); //Not sure if this is a good way to pass back a value
  }
  </code></pre>
  
  <p>Class:</p>
  
  <pre><code>namespace MQListener
  {
      class MessageQueue : MQ.MessageListener
      {
          public event EventHandler MsgTrigger;
  
          public virtual void onMessage(MQ.Message Message)
          {
              MQ.TextMessage txtMessage = (MQ.TextMessage)Message;
              String MsgBody = txtMessage.getMessage();
              Console.WriteLine(MsgBody);
  
              object objMsg = (object)MsgBody;
  
              var _Trigger = MsgTrigger;
  
                  if(_Trigger != null)
                     _Trigger(objMsg, null);
          }
      }
  }
  </code></pre>