SPSystemPerformanceCounterMonitor.Value property
取得目前的基礎計數器值。
Namespace: Microsoft.SharePoint.Utilities
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Overrides ReadOnly Property Value As Object
Get
'用途
Dim instance As SPSystemPerformanceCounterMonitor
Dim value As Object
value = instance.Value
public override Object Value { get; }
Property value
Type: System.Object
目前的計數器值。
Implements
備註
如果由於任何原因而無法讀取基礎計數器, Value設為0.0 f ,錯誤訊息會指派給CounterError。
讀取Value的內容將LastValue屬性設定為相同的值。如果您的程式碼需要超過一次取得傳回的計數器值,呼叫LastValue屬性為第二個和所有後續的讀數。
Examples
下列的範例程式碼顯示使用中的屬性。如需完整的範例,請參閱。
// 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 class