且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何获取仅包含消息的队列名称,以及如何计算在控制台应用程序中具有消息的每个队列上的消息?

更新时间:2023-11-25 12:57:40

MSDN帮助页面提供有关的MessageQueue ;你有解决问题所需的一切:

https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.getprivatequeuesbymachine%28v=vs.110%29.aspx [ ^ ],

MessageQueue类(System.Messaging) [ ^ ],

MessageQueue.GetAllMessages方法(System.Messaging) [ ^ ]。



注意 GetAllMessages 函数的最后一个链接。它返回消息数组,您可以使用它来查看是否有消息。只需调用数组的属性长度



不清楚你的意思是有多少消息和邮件正文;这个表达式在语法上和逻辑上都不正确。无论如何,获取消息数组并查看你想要的任何内容。



-SA
MSDN help page provide comprehensive information on MessageQueue; you have all you need to solve your problem:
https://msdn.microsoft.com/en-us/library/system.messaging.messagequeue.getprivatequeuesbymachine%28v=vs.110%29.aspx[^],
MessageQueue Class (System.Messaging)[^],
MessageQueue.GetAllMessages Method (System.Messaging)[^].

Note the last link to the GetAllMessages function. It returns the message array, which you can use to see if there any messages. Just call the array's property Length.

It's not clear what you mean by "how many messages are there and message body"; this expression is not grammatically and logically correct. Anyway, get the message array and look at whatever you want.

—SA