I have code which read remote MSMQ queue and outputs messages to the screen. Problem is that code continues executing while Stream is being received on the client. How do I make code to wait to finish execution.
[Reflection.Assembly]::LoadWithPartialName("System.Messaging") | out-Null $QueueName = "FormatName:DIRECT=OS:computer1\private$\an" $QueuesFromDotNet = new-object System.Messaging.MessageQueue $QueueName $msg = $QueuesFromDotNet.Peek() line 10: $content = [System.Text.UTF8Encoding]::UTF8.GetString($msg.BodyStream.ToArray()) $content
I want code to wait on line 10 untill BodyStream.ToArray() received entire contents of the message.