C# 清理消息管道的消息

时间:2023-03-10 01:23:16
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();
}

}
}

C# 清理消息管道的消息