Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何阻止自定义性能计数器实例名称自动转换为小写_C#_Performance - Fatal编程技术网

C# 如何阻止自定义性能计数器实例名称自动转换为小写

C# 如何阻止自定义性能计数器实例名称自动转换为小写,c#,performance,C#,Performance,我已经创建了一个多实例性能计数器,并将混合大小写的实例名传递给它,但当我通过代码和perfmon查看它们时,实例名会以某种方式转换为小写。有人知道如何预防吗?在google上找到的,觉得Luke Zhang没有跟进真是太好了。我使用Reflector查看System.dll中的代码以获取PerformanceCounter。在私有初始化事件中,有一个小金块: this.sharedCounter = new SharedPerformanceCounter(categoryName.ToLowe

我已经创建了一个多实例性能计数器,并将混合大小写的实例名传递给它,但当我通过代码和perfmon查看它们时,实例名会以某种方式转换为小写。有人知道如何预防吗?在google上找到的,觉得Luke Zhang没有跟进真是太好了。

我使用Reflector查看System.dll中的代码以获取PerformanceCounter。在私有初始化事件中,有一个小金块:

this.sharedCounter = new SharedPerformanceCounter(categoryName.ToLower(CultureInfo.InvariantCulture), this.counterName.ToLower(CultureInfo.InvariantCulture), this.instanceName.ToLower(CultureInfo.InvariantCulture), this.instanceLifetime);

我想这就是原因。

为什么?(这个简单的问题是不够的,尽管它在上下文中完全有意义。无论如何,我可以随时再写几个字。)aa 2017年的情况仍然如此。。。。。您甚至不需要使用Reflector/dotPeek,它位于参考源中: