• msmq中消息的数量



    using System.Diagnostics;

    PerformanceCounter objCounter = new PerformanceCounter("MSMQ Queue", "Messages in Queue", @"mymachineprivate$MyQueue");

    int count = (int)(objCounter.NextValue());

    //MSMQ性能计数器
    PerformanceCounterCategory countCategory = new PerformanceCounterCategory("MSMQ Queue");

    //所有消息队列数量
    PerformanceCounter allCount = new PerformanceCounter("MSMQ Queue", "Messages in Queue");
    foreach (string instanceName in countCategory.GetInstanceNames())
    {
    allCount.InstanceName = instanceName;//需要给实例名赋值
    Console.WriteLine(string.Format("{0} 数量:{1}", allCount.InstanceName, allCount.NextValue().ToString()));
    }


    //单个消息队列数量
    PerformanceCounter singleCount = new PerformanceCounter("MSMQ Queue", "Messages in Queue", Environment.MachineName + "\private$\queue_demo");
    singleCount.InstanceName = Environment.MachineName + "\private$\queue_demo";
    Console.WriteLine(string.Format("{0} 数量:{1}", singleCount.InstanceName, singleCount.NextValue().ToString()));

  • 相关阅读:
    递归的初步应用
    最大公约数与最小公倍数(低效)
    进制转换
    凸多边形的面积问题
    单词替换
    DNA排序
    字符串排序
    倒三角形
    韩信点兵
    oracle
  • 原文地址:https://www.cnblogs.com/wcLT/p/4331543.html
Copyright © 2020-2023  润新知