本文整理汇总了VB.NET中System.Messaging.MessageQueue.Create方法的典型用法代码示例。如果您正苦于以下问题:VB.NET MessageQueue.Create方法的具体用法?VB.NET MessageQueue.Create怎么用?VB.NET MessageQueue.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Messaging.MessageQueue 的用法示例。
在下文中一共展示了MessageQueue.Create方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: MyNewQueue
' 导入命名空间
Imports System.Messaging
' Provides a container class for the example.
Public Class MyNewQueue
' Provides an entry point into the application.
'
' This example creates new public and private
' queues.
Public Shared Sub Main()
' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue()
' Create public and private queues.
myNewQueue.CreatePublicQueues()
myNewQueue.CreatePrivateQueues()
Return
End Sub
' Creates public queues and sends a message.
Public Sub CreatePublicQueues()
' Create and connect to a public Message Queuing queue.
If Not MessageQueue.Exists(".\newPublicQueue") Then
' Create the queue if it does not exist.
Dim myNewPublicQueue As MessageQueue = _
MessageQueue.Create(".\newPublicQueue")
' Send a message to the queue.
myNewPublicQueue.Send("My message data.")
End If
' Create (but do not connect to) a second public queue.
If Not MessageQueue.Exists(".\newPublicResponseQueue") _
Then
MessageQueue.Create(".\newPublicResponseQueue")
End If
Return
End Sub
' Creates private queues and sends a message.
Public Sub CreatePrivateQueues()
' Create and connect to a private Message Queuing queue.
If Not MessageQueue.Exists(".\Private$\newPrivateQueue") _
Then
' Create the queue if it does not exist.
Dim myNewPrivateQueue As MessageQueue = _
MessageQueue.Create(".\Private$\newPrivateQueue")
' Send a message to the queue.
myNewPrivateQueue.Send("My message data.")
End If
' Create (but do not connect to) a second private queue.
If Not MessageQueue.Exists(".\Private$\newResponseQueue") _
Then
MessageQueue.Create(".\Private$\newResponseQueue")
End If
Return
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Messaging,代码行数:87,代码来源:MessageQueue.Create
示例2: MyNewQueue
' 导入命名空间
Imports System.Messaging
Public Class MyNewQueue
' Provides an entry point into the application.
'
' This example creates new transactional queues.
Public Shared Sub Main()
' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue
' Create transactional queues.
myNewQueue.CreatePublicTransactionalQueues()
myNewQueue.CreatePrivateTransactionalQueues()
Return
End Sub
' Creates public transactional queues and sends a
' message.
Public Sub CreatePublicTransactionalQueues()
' Create and connect to a public Message Queuing queue.
If Not MessageQueue.Exists(".\newPublicTransQueue1") Then
' Create the queue if it does not exist.
MessageQueue.Create(".\newPublicTransQueue1", True)
End If
' Connect to the queue.
Dim myNewPublicQueue As New MessageQueue(".\newPublicTransQueue1")
' Create a transaction.
Dim myTransaction As New MessageQueueTransaction
' Begin the transaction.
myTransaction.Begin()
' Send the message.
myNewPublicQueue.Send("My Message Data.", myTransaction)
' Commit the transaction.
myTransaction.Commit()
If Not MessageQueue.Exists(".\newPublicTransQueue2") Then
' Create (but do not connect to) a second queue.
MessageQueue.Create(".\newPublicTransQueue2", True)
End If
Return
End Sub
' Creates private queues and sends a message.
Public Sub CreatePrivateTransactionalQueues()
' Create and connect to a private Message Queuing queue.
If Not MessageQueue.Exists(".\Private$\newPrivTransQ1") _
Then
' Create the queue if it does not exist.
MessageQueue.Create(".\Private$\newPrivTransQ1", True)
End If
' Connect to the queue.
Dim myNewPrivateQueue As New MessageQueue(".\Private$\newPrivTransQ1")
' Create a transaction.
Dim myTransaction As New MessageQueueTransaction
' Begin the transaction.
myTransaction.Begin()
' Send the message.
myNewPrivateQueue.Send("My Message Data.", myTransaction)
' Commit the transaction.
myTransaction.Commit()
' Create (but do not connect to) a second private queue.
If Not MessageQueue.Exists(".\Private$\newPrivTransQ2") _
Then
MessageQueue.Create(".\Private$\newPrivTransQ2", True)
End If
Return
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Messaging,代码行数:108,代码来源:MessageQueue.Create
示例3: MainClass
' 导入命名空间
Imports System
Imports System.Messaging
Public Class MainClass
Shared Sub Main()
Dim Greeting As String = "Hello World!"
Dim mQ As MessageQueue
If MessageQueue.Exists(".\Private$\HelloWorld") Then
mQ = New MessageQueue(".\Private$\HelloWorld")
Else
mQ = MessageQueue.Create(".\Private$\HelloWorld")
End If
mQ.Send(Greeting, "HelloWorld")
Console.WriteLine("Greeting Message Sent to Private Queue.")
End Sub
End Class
开发者ID:VB程序员,项目名称:System.Messaging,代码行数:19,代码来源:MessageQueue.Create
注:本文中的System.Messaging.MessageQueue.Create方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论