本文整理匯總了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;
}
}
}