本文整理汇总了VB.NET中System.Messaging.MessageQueue.MessageQueue构造函数的典型用法代码示例。如果您正苦于以下问题:VB.NET MessageQueue构造函数的具体用法?VB.NET MessageQueue怎么用?VB.NET MessageQueue使用的例子?那么, 这里精选的构造函数代码示例或许可以为您提供帮助。您也可以进一步了解该构造函数所在类System.Messaging.MessageQueue
的用法示例。
在下文中一共展示了MessageQueue构造函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: MyNewQueue
' 导入命名空间
Imports System.Messaging
Public Class MyNewQueue
' Provides an entry point into the application.
'
' This example demonstrates several ways to set
' a queue's path.
Public Shared Sub Main()
' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue()
myNewQueue.SendPublic()
myNewQueue.SendPrivate()
myNewQueue.SendByLabel()
myNewQueue.SendByFormatName()
myNewQueue.MonitorComputerJournal()
myNewQueue.MonitorQueueJournal()
myNewQueue.MonitorDeadLetter()
myNewQueue.MonitorTransactionalDeadLetter()
Return
End Sub
' References public queues.
Public Sub SendPublic()
Dim myQueue As New MessageQueue(".\myQueue")
myQueue.Send("Public queue by path name.")
Return
End Sub
' References private queues.
Public Sub SendPrivate()
Dim myQueue As New MessageQueue(".\Private$\myQueue")
myQueue.Send("Private queue by path name.")
Return
End Sub
' References queues by label.
Public Sub SendByLabel()
Dim myQueue As New MessageQueue("Label:TheLabel")
myQueue.Send("Queue by label.")
Return
End Sub
' References queues by format name.
Public Sub SendByFormatName()
Dim myQueue As New _
MessageQueue("FormatName:Public=" + _
"5A5F7535-AE9A-41d4-935C-845C2AFF7112")
myQueue.Send("Queue by format name.")
Return
End Sub
' References computer journal queues.
Public Sub MonitorComputerJournal()
Dim computerJournal As New MessageQueue(".\Journal$")
While True
Dim journalMessage As Message = _
computerJournal.Receive()
' Process the journal message.
End While
Return
End Sub
' References queue journal queues.
Public Sub MonitorQueueJournal()
Dim queueJournal As New _
MessageQueue(".\myQueue\Journal$")
While True
Dim journalMessage As Message = _
queueJournal.Receive()
' Process the journal message.
End While
Return
End Sub
' References dead-letter queues.
Public Sub MonitorDeadLetter()
Dim deadLetter As New MessageQueue(".\DeadLetter$")
While True
Dim deadMessage As Message = deadLetter.Receive()
' Process the dead-letter message.
End While
Return
End Sub
' References transactional dead-letter queues.
Public Sub MonitorTransactionalDeadLetter()
Dim TxDeadLetter As New MessageQueue(".\XactDeadLetter$")
While True
Dim txDeadLetterMessage As Message = _
TxDeadLetter.Receive()
' Process the transactional dead-letter message.
End While
Return
End Sub
End Class
示例2: MyNewQueue
' 导入命名空间
Imports System.Messaging
Public Class MyNewQueue
' Provides an entry point into the application.
'
' This example connects to a message queue, and
' requests exclusive read access to the queue.
Public Shared Sub Main()
' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue()
' Output the count of Lowest priority messages.
myNewQueue.GetExclusiveAccess()
Return
End Sub
' Requests exlusive read access to the queue. If
' access is granted, receives a message from the
' queue.
Public Sub GetExclusiveAccess()
Try
' Request exclusive read access to the queue.
Dim myQueue As New MessageQueue(".\myQueue", True)
' Receive a message. This is where a SharingViolation
' exception would be thrown.
Dim myMessage As Message = myQueue.Receive()
Catch e As MessageQueueException
' Handle request for denial of exclusive read access.
If e.MessageQueueErrorCode = _
MessageQueueErrorCode.SharingViolation Then
Console.WriteLine("Denied exclusive read access.")
End If
' Handle other sources of a MessageQueueException.
' Handle other exceptions as necessary.
End Try
Return
End Sub
End Class