C# 清理消息管道的消息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Messaging;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{

class Program
{
static void Main(string[] args)
{
//
var qs = MessageQueue.GetPrivateQueuesByMachine("isc-2065");// 机器名
MessageQueue queue = new MessageQueue("FormatName:DIRECT=OS:isc-2065\private$\spc/msmqyahooservice.svc");//对应的消息管道
// Delete all messages from the queue.

queue.Purge();
}

}
}

原文地址:https://www.cnblogs.com/c-x-a/p/5393991.html