示例
[Visual Basic, C#] 下面的示例连接到消息队列并将消息发送到该队列。[Visual Basic]
Imports System
Imports System.MessagingNamespace MyProject
'/ <summary>
'/ Provides a container class for the example.
'/ </summary>
Public Class MyNewQueue
'**************************************************
' Provides an entry point into the application.
'
' This example sends a message to a queue.
'************************************************** Public Shared Sub Main() ' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue() ' Send a message to a queue.
myNewQueue.SendMessage() Return End Sub 'Main
'**************************************************
' Sends a message to a queue.
'************************************************** Public Sub SendMessage() ' Connect to a queue on the local computer.
Dim myQueue As New MessageQueue(".\myQueue") ' Send a message to the queue.
If myQueue.Transactional = True Then
myQueue.Send("My Message Data.", New _
MessageQueueTransaction())
Else
myQueue.Send("My Message Data.")
End If Return End Sub 'SendMessage End Class 'MyNewQueue
End Namespace 'MyProject
[C#]
using System;
using System.Messaging;namespace MyProject
{ /// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{ //**************************************************
// Provides an entry point into the application.
//
// This example sends a message to a queue.
//************************************************** public static void Main()
{
// Create a new instance of the class.
MyNewQueue myNewQueue = new MyNewQueue(); // Send a message to a queue.
myNewQueue.SendMessage(); return;
}
//**************************************************
// Sends a message to a queue.
//**************************************************
public void SendMessage()
{
// Connect to a queue on the local computer.
MessageQueue myQueue = new MessageQueue(".\\myQueue"); // Send a message to the queue.
if (myQueue.Transactional == true)
{
myQueue.Send("My Message Data.", new
MessageQueueTransaction());
}
else
{
myQueue.Send("My Message Data.");
} return;
}
}
}
不知道对你有没有帮助!
[Visual Basic, C#] 下面的示例连接到消息队列并将消息发送到该队列。[Visual Basic]
Imports System
Imports System.MessagingNamespace MyProject
'/ <summary>
'/ Provides a container class for the example.
'/ </summary>
Public Class MyNewQueue
'**************************************************
' Provides an entry point into the application.
'
' This example sends a message to a queue.
'************************************************** Public Shared Sub Main() ' Create a new instance of the class.
Dim myNewQueue As New MyNewQueue() ' Send a message to a queue.
myNewQueue.SendMessage() Return End Sub 'Main
'**************************************************
' Sends a message to a queue.
'************************************************** Public Sub SendMessage() ' Connect to a queue on the local computer.
Dim myQueue As New MessageQueue(".\myQueue") ' Send a message to the queue.
If myQueue.Transactional = True Then
myQueue.Send("My Message Data.", New _
MessageQueueTransaction())
Else
myQueue.Send("My Message Data.")
End If Return End Sub 'SendMessage End Class 'MyNewQueue
End Namespace 'MyProject
[C#]
using System;
using System.Messaging;namespace MyProject
{ /// <summary>
/// Provides a container class for the example.
/// </summary>
public class MyNewQueue
{ //**************************************************
// Provides an entry point into the application.
//
// This example sends a message to a queue.
//************************************************** public static void Main()
{
// Create a new instance of the class.
MyNewQueue myNewQueue = new MyNewQueue(); // Send a message to a queue.
myNewQueue.SendMessage(); return;
}
//**************************************************
// Sends a message to a queue.
//**************************************************
public void SendMessage()
{
// Connect to a queue on the local computer.
MessageQueue myQueue = new MessageQueue(".\\myQueue"); // Send a message to the queue.
if (myQueue.Transactional == true)
{
myQueue.Send("My Message Data.", new
MessageQueueTransaction());
}
else
{
myQueue.Send("My Message Data.");
} return;
}
}
}
不知道对你有没有帮助!
解决方案 »
- DataGridView分页的问题,请高手来看看,谢谢
- 求上传下载附件c#源码或方法(急)
- C# 手机短信
- 为什么TabContainer控件页面不显示
- 求救!!在C#中的服务(System.ServiceProcess.ServiceBase)强制进行垃圾回收,WaitForPendingFinalizers()函数被阻塞
- 如何将单字节转换成双字节?
- 绘图方面的问题,先谢谢了!!
- c# 应用程序中Dataform的使用问题,解决拉马上给分,不管多少!!!!!
- 有关 string.Split() 求救.
- C#使用NPOI写入excel时设置Hyperlink问题
- 微软的.net框架类库FCL在哪里可以查到有关它的说明,MSDN吗?有没有象JDK API一样的东东?
- .net里面的线程问题,欢迎大家讨论!
吗?