本文主要是介绍Consistently Declare objects in Webservices,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1句話
不要忘記 webservice 也是一個 class
是 class 就有 constructor
以上。
protected PerformanceCounter cpuUsage;// = new PerformanceCounter("Processor", "% Processor Time", "_Total");protected PerformanceCounter ramUsage;// = new PerformanceCounter("Memory", "Available MBytes");//protected CounterSample sample;public monitor(){cpuUsage = new PerformanceCounter("Processor", "% Processor Time", "_Total");ramUsage = new PerformanceCounter("Memory", "Available MBytes");//sample = cpuUsage.NextSample();}[WebMethod]public float getHostCpuUsage(){cpuUsage.NextValue();Thread.Sleep(100);cpuUsage.NextValue();Thread.Sleep(100);return cpuUsage.NextValue();}[WebMethod]public float getHostMemUsage(){return ramUsage.NextValue();}
这篇关于Consistently Declare objects in Webservices的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!