本文整理匯總了C#中System.Messaging.MessageQueuePermissionAccess枚舉的典型用法代碼示例。如果您正苦於以下問題:C# MessageQueuePermissionAccess枚舉的具體用法?C# MessageQueuePermissionAccess怎麽用?C# MessageQueuePermissionAccess使用的例子?那麽, 這裏精選的枚舉代碼示例或許可以為您提供幫助。
在下文中一共展示了MessageQueuePermissionAccess枚舉的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
//引入命名空間
using System;
using System.Messaging;
public class MessageQueuePermissionAccessExample
{
public static void Main()
{
// Create a new instance of the class.
MessageQueuePermissionAccessExample example =
new MessageQueuePermissionAccessExample();
// Create a non-transactional queue on the local computer.
CreateQueue(".\\exampleQueue", false);
// Demonstrate use of MessageQueuePermissionAccess.
example.CreatePermission();
}
// Creates a new queue.
public static void CreateQueue(string queuePath, bool transactional)
{
if(!MessageQueue.Exists(queuePath))
{
MessageQueue.Create(queuePath, transactional);
}
else
{
Console.WriteLine(queuePath + " already exists.");
}
}
// Demonstrates the use of MessageQueuePermissionAccess
public void CreatePermission()
{
// Connect to a queue on the local computer.
MessageQueue queue = new MessageQueue(".\\exampleQueue");
string machineName = queue.MachineName;
string label = queue.Label;
string category = queue.Category.ToString();
// Create a new instance of MessageQueuePermission.
MessageQueuePermission permission = new MessageQueuePermission(
MessageQueuePermissionAccess.Receive,
machineName,
label,
category);
}
}