zoukankan      html  css  js  c++  java
  • 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()));

  • 相关阅读:
    【笔记】隐式寻址方式(pending...)
    【笔记】有结构文件(pending...)
    【笔记】目录项(pending...)
    【笔记】主存储器
    Ubuntu 16.04 升级OpenSSH至7.7p1
    awk用法笔记
    find命令笔记
    VIM的使用
    Shell
    Linux文本处理三剑客
  • 原文地址:https://www.cnblogs.com/wcLT/p/4331543.html
Copyright © 2011-2022 走看看