本文整理汇总了C#中System.Messaging.DefaultPropertiesToSend类的典型用法代码示例。如果您正苦于以下问题:C# DefaultPropertiesToSend类的具体用法?C# DefaultPropertiesToSend怎么用?C# DefaultPropertiesToSend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultPropertiesToSend类属于System.Messaging命名空间,在下文中一共展示了DefaultPropertiesToSend类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
//引入命名空间
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 specifies different types of default
// properties for messages.
//**************************************************
public static void Main()
{
// Create a new instance of the class.
MyNewQueue myNewQueue = new MyNewQueue();
// Send normal and high priority messages.
myNewQueue.SendNormalPriorityMessages();
myNewQueue.SendHighPriorityMessages();
return;
}
//**************************************************
// Associates selected message property values
// with high priority messages.
//**************************************************
public void SendHighPriorityMessages()
{
// Connect to a message queue.
MessageQueue myQueue = new
MessageQueue(".\\myQueue");
// Associate selected default property values with high
// priority messages.
myQueue.DefaultPropertiesToSend.Priority =
MessagePriority.High;
myQueue.DefaultPropertiesToSend.Label =
"High Priority Message";
myQueue.DefaultPropertiesToSend.Recoverable = true;
myQueue.DefaultPropertiesToSend.TimeToReachQueue =
new TimeSpan(0,0,30);
// Send messages using these defaults.
myQueue.Send("High priority message data 1.");
myQueue.Send("High priority message data 2.");
myQueue.Send("High priority message data 3.");
return;
}
//**************************************************
// Associates selected message property values
// with normal priority messages.
//**************************************************
public void SendNormalPriorityMessages()
{
// Connect to a message queue.
MessageQueue myQueue = new MessageQueue(".\\myQueue");
// Associate selected default property values with normal
// priority messages.
myQueue.DefaultPropertiesToSend.Priority =
MessagePriority.Normal;
myQueue.DefaultPropertiesToSend.Label =
"Normal Priority Message";
myQueue.DefaultPropertiesToSend.Recoverable = false;
myQueue.DefaultPropertiesToSend.TimeToReachQueue =
new TimeSpan(0,2,0);
// Send messages using these defaults.
myQueue.Send("Normal priority message data 1.");
myQueue.Send("Normal priority message data 2.");
myQueue.Send("Normal priority message data 3.");
return;
}
}
}