title: Handle a message I just sent with ActiveMQ and C#
body: <p>I'm a beginner at using ActiveMQ with C#. I've created a simple windows form with one button and one label. When I click on the button, i send a message to the queue and the label is initialized with the message I just sent. Of course, I could initialize my label directly but I want my form to rather consume the message from the queue in order to update my label.</p>
  
  <p>The problem is I don't manage to handle the message in the same form to update my label. My consumer code is not called at all and yet, its initialized in the Load event of my form.
  Here's the code</p>
  
  <pre><code>    protected override void OnLoad(EventArgs e)
      {
          base.OnLoad(e);
          InitializeHandlerAMQ();
      }
  
      private void InitializeHandlerAMQ()
      {
          Tchat tchat = null;
          IDestination dest = _session.GetQueue(QUEUE_DESTINATION);
          using(IMessageConsumer consumer = _session.CreateConsumer(dest))
          {
              IMessage message;
              while((message = consumer.Receive(TimeSpan.FromMilliseconds(2000))) != null)
              {
                  var objectMessage = message as IObjectMessage;
                  if(objectMessage != null)
                  {
                      tchat = objectMessage.Body as Tchat;
                      if (tchat != null)
                      {
                          textBox2.Text += string.Format("{0}{1}", tchat.Message, Environment.NewLine);
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>If I close my windows form and restart it, then my label is well updated but I don't want to close it and re open it. </p>
  
  <p>Do you have any ideas guys ?</p>