本文整理汇总了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);
}
}