SPSystemPerformanceCounterMonitor.Value 属性
获取基础计数器的当前值。
命名空间: Microsoft.SharePoint.Utilities
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Overrides ReadOnly Property Value As Object
Get
用法
Dim instance As SPSystemPerformanceCounterMonitor
Dim value As Object
value = instance.Value
public override Object Value { get; }
属性值
类型:System.Object
计数器的当前值。
实现
备注
如果由于任何原因无法读取基础计数器, Value设置为0.0 f和一条错误消息分配给CounterError。
读取Value属性将LastValue属性设置为相同的值。如果您的代码需要不止一次收到一个返回的计数器值,寻求第二次和随后的所有读数的LastValue属性。
示例
下面的代码示例演示使用中的属性。有关完整的示例,请参见。
// Get a reference to the throttle settings
Uri webApplicationUri = new Uri("Http://localhost/");
SPWebApplication webApplication = SPWebApplication.Lookup(webApplicationUri);
SPHttpThrottleSettings throttleSettings = SPHttpThrottleSettings.GetHttpThrottleSettings(webApplication);
// Get a reference to the monitor whose value is to be read
SPSystemPerformanceMonitorCollection monitors = throttleSettings.GenerateMonitors();
SPSystemPerformanceCounterMonitor counterMonitor = (SPSystemPerformanceCounterMonitor)monitors[monitors.Count - 1];
// Read the value
double currentValue = Convert.ToDouble(counterMonitor.Value);
Console.WriteLine(currentValue.ToString());
' Get a reference to the throttle settings
Dim webApplicationUri As New Uri("Http://localhost/")
Dim webApplication As SPWebApplication = SPWebApplication.Lookup(webApplicationUri)
Dim throttleSettings As SPHttpThrottleSettings = SPHttpThrottleSettings.GetHttpThrottleSettings(webApplication)
' Get a reference to the monitor whose value is to be read
Dim monitors As SPSystemPerformanceMonitorCollection = throttleSettings.GenerateMonitors()
Dim counterMonitor As SPSystemPerformanceCounterMonitor = CType(monitors(monitors.Count - 1), SPSystemPerformanceCounterMonitor)
' Read the value
Dim currentValue As Double = Convert.ToDouble(counterMonitor.Value)
Console.WriteLine(currentValue.ToString())
另请参阅
引用
SPSystemPerformanceCounterMonitor 类