MessageQueue.Receive : MessageQueue « System.Messaging « VB.Net by API






MessageQueue.Receive

   

Imports System
Imports System.IO
Imports System.Messaging

Public Class MainClass
    
    Shared Sub Main()
        Dim mQ As MessageQueue
        Dim mes As Message
        Dim X As String
        Dim br As BinaryReader

        If MessageQueue.Exists(".\Private$\HelloWorld") Then
            mQ = New MessageQueue(".\Private$\HelloWorld")
        Else
            Console.WriteLine("Queue doesn't exist.")
            Return
        End If

        Try
            mes = mQ.Receive(New TimeSpan(0, 0, 3))
            br = New BinaryReader(mes.BodyStream)
            X = New String(br.ReadChars(CType(mes.BodyStream.Length, Integer)))
            Console.WriteLine("Received Message: {0}", X)
        Catch
            Console.WriteLine("No Message to Receive.")
        End Try
    End Sub
End Class

   
    
    
  








Related examples in the same category

1.New MessageQueue
2.MessageQueue.Create
3.MessageQueue.Exists
4.MessageQueue.Send