title: want to read msmq message fast using safe thread in c# .net
body: <p>i want to read the MSMQ where queue data in byte and numbers of queues generated in 1 mins about 1500. so if read continuously queue cpu goes on 30%. and after some time it stopped. i need to read queue in high volume upto 4 hrs..
  so i want safe thread reading in such a manner that shouldn't be block.
  actually i am not good about threading so can you please help me out..</p>
  
  <p>currently i am reading in this manner</p>
  
  <pre><code>    bool ProcessStatus; //process
      Thread _UDPthreadConsme;
  
      private void btn_receive_Click(object sender, EventArgs e)
      {
  
      if (MessageQueue.Exists(@".\private$\myquelocal"))
      {
  
      ThreadStart _processrcs = new ThreadStart(receivemessages);
      _UDPthreadConsme = new Thread(_processrcs);
      ProcessStatus = true;
      _UDPthreadConsme.Start();
      }
      }
  
  
      private void receivemessages()
      {
      MessageBox.Show("Start");
      while (ProcessStatus)
      {
      try
      {
  
      // Connect to the a queue on the local computer.
      MessageQueue myQueue = new MessageQueue(@".\private$\myquelocal");
  
  
      System.Messaging.Message[] myMessagecount = myQueue.GetAllMessages();
  
      if (myMessagecount.Length &lt;= 0)
      return;
  
  
      myQueue.Formatter = new BinaryMessageFormatter();
  
      // Receive and format the message.
      System.Messaging.Message myMessage = myQueue.Receive();
      byte[] buffer = (byte[])myMessage.Body;
  
  // here i convert buffer to its related structure and then insert the values in database sqlserver.
  
  }
  } 
  </code></pre>