다음을 통해 공유


SPSystemPerformanceCounterMonitor.Value Property

Gets the current value of the underlying counter.

Namespace:  Microsoft.SharePoint.Utilities
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
Public Overrides ReadOnly Property Value As Object
    Get
'Usage
Dim instance As SPSystemPerformanceCounterMonitor
Dim value As Object

value = instance.Value
public override Object Value { get; }

Property Value

Type: System.Object
The current value of the counter.

Implements

ISPPerformanceMonitor.Value

Remarks

If the underlying counter cannot be read for any reason, Value is set to 0.0f and an error message is assigned to CounterError.

Reading the Value property sets the LastValue property to the same value. If your code needs to get a returned counter value more than once, call the LastValue property for the second and all subsequent readings.

Examples

The following sample code shows the property in use. For the full example, see .

// 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())

See Also

Reference

SPSystemPerformanceCounterMonitor Class

SPSystemPerformanceCounterMonitor Members

Microsoft.SharePoint.Utilities Namespace