Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. msmq stackoverflow exception

msmq stackoverflow exception

Scheduled Pinned Locked Moved C#
csharphelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    poqeqw
    wrote on last edited by
    #1

    I am writeing windows service that makes use in MSMQ in .net 2003 in c#. I user the method beginPeek(TimeSpan) and waiting for an message to arrive the event handler look like this: private void MyPeekCompleted(Object source, PeekCompletedEventArgs asyncResult) { try { // End the asynchronous peek operation. Message m = _mq.EndPeek(asyncResult.AsyncResult); //logic to handel message mq.BeginPeek(new TimeSpan(0,1,0)); } catch(MessageQueueException e) { if (e.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout) { Console.WriteLine(e.ToString()); } _mq.BeginPeek(new TimeSpan(0,1,0)); } catch(Exception ex) { // some code to handel error } after a while i get stackoverflow exception. event though no message arrives... It works fike for a couple of minuts and than crushes.. How can i solve this.. Sample code will be greate help.. im using winXP Thnks

    L 1 Reply Last reply
    0
    • P poqeqw

      I am writeing windows service that makes use in MSMQ in .net 2003 in c#. I user the method beginPeek(TimeSpan) and waiting for an message to arrive the event handler look like this: private void MyPeekCompleted(Object source, PeekCompletedEventArgs asyncResult) { try { // End the asynchronous peek operation. Message m = _mq.EndPeek(asyncResult.AsyncResult); //logic to handel message mq.BeginPeek(new TimeSpan(0,1,0)); } catch(MessageQueueException e) { if (e.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout) { Console.WriteLine(e.ToString()); } _mq.BeginPeek(new TimeSpan(0,1,0)); } catch(Exception ex) { // some code to handel error } after a while i get stackoverflow exception. event though no message arrives... It works fike for a couple of minuts and than crushes.. How can i solve this.. Sample code will be greate help.. im using winXP Thnks

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, I have no experience in this, but I see a logical problem in your code. the MSDN example has BeginPeek as the last statement in the PeekCompleted handler. Yours has more than one BeginPeek, and they are not at the end, so if they complete before you have left the Completed handler (Console.WriteLine will take some msecs), a new one would be launched before the current one exits, consuming stack space. Hope this helps.

      Luc Pattyn [Forum Guidelines] [My Articles]


      this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


      P 2 Replies Last reply
      0
      • L Luc Pattyn

        Hi, I have no experience in this, but I see a logical problem in your code. the MSDN example has BeginPeek as the last statement in the PeekCompleted handler. Yours has more than one BeginPeek, and they are not at the end, so if they complete before you have left the Completed handler (Console.WriteLine will take some msecs), a new one would be launched before the current one exits, consuming stack space. Hope this helps.

        Luc Pattyn [Forum Guidelines] [My Articles]


        this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


        P Offline
        P Offline
        poqeqw
        wrote on last edited by
        #3

        yhanks for the I dont understnd what you mean can you pleas wexplain again

        1 Reply Last reply
        0
        • L Luc Pattyn

          Hi, I have no experience in this, but I see a logical problem in your code. the MSDN example has BeginPeek as the last statement in the PeekCompleted handler. Yours has more than one BeginPeek, and they are not at the end, so if they complete before you have left the Completed handler (Console.WriteLine will take some msecs), a new one would be launched before the current one exits, consuming stack space. Hope this helps.

          Luc Pattyn [Forum Guidelines] [My Articles]


          this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


          P Offline
          P Offline
          poqeqw
          wrote on last edited by
          #4

          Mire over i have 2 begin peek because i have to continue waiting for a message one begin peek is in call if no exception and the other if an exception happen so they will never happen at the same time

          L 1 Reply Last reply
          0
          • P poqeqw

            Mire over i have 2 begin peek because i have to continue waiting for a message one begin peek is in call if no exception and the other if an exception happen so they will never happen at the same time

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Hi, this is my suggestion: remove the BeginPeeks you have, and put a single mq.BeginPeek(new TimeSpan(0,1,0)); as the very last line of the PeekCompleted handler. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google


            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups