您的位置:首页 > 移动开发 > Objective-C

Consistently Declare objects in Webservices

2011-09-06 21:32 162 查看
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();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: