Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

AFData.RecordedValuesByCountAsync Method

  • Last UpdatedNov 18, 2025
  • 5 minute read
AFData.RecordedValuesByCountAsync Method
This method returns a specified number of compressed values beginning at the requested start time in the direction specified.

Namespace:  OSIsoft.AF.Data
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

public Task<AFValues> RecordedValuesByCountAsync(
	AFTime startTime,
	int count,
	bool forward,
	AFBoundaryType boundaryType,
	UOM desiredUOM,
	string filterExpression,
	bool includeFilteredValues,
	CancellationToken cancellationToken = default
)
Public Function RecordedValuesByCountAsync ( 
	startTime As AFTime,
	count As Integer,
	forward As Boolean,
	boundaryType As AFBoundaryType,
	desiredUOM As UOM,
	filterExpression As String,
	includeFilteredValues As Boolean,
	Optional cancellationToken As CancellationToken = Nothing
) As Task(Of AFValues)

Dim instance As AFData
Dim startTime As AFTime
Dim count As Integer
Dim forward As Boolean
Dim boundaryType As AFBoundaryType
Dim desiredUOM As UOM
Dim filterExpression As String
Dim includeFilteredValues As Boolean
Dim cancellationToken As CancellationToken
Dim returnValue As Task(Of AFValues)

returnValue = instance.RecordedValuesByCountAsync(startTime, 
	count, forward, boundaryType, desiredUOM, 
	filterExpression, includeFilteredValues, 
	cancellationToken)
public:
Task<AFValues^>^ RecordedValuesByCountAsync(
	AFTime startTime, 
	int count, 
	bool forward, 
	AFBoundaryType boundaryType, 
	UOM^ desiredUOM, 
	String^ filterExpression, 
	bool includeFilteredValues, 
	CancellationToken cancellationToken = CancellationToken()
)
member RecordedValuesByCountAsync : 
        startTime : AFTime * 
        count : int * 
        forward : bool * 
        boundaryType : AFBoundaryType * 
        desiredUOM : UOM * 
        filterExpression : string * 
        includeFilteredValues : bool * 
        ?cancellationToken : CancellationToken 
(* Defaults:
        let _cancellationToken = defaultArg cancellationToken new CancellationToken()
*)
-> Task<AFValues> 

Parameters

startTime
Type: OSIsoft.AF.TimeAFTime
The start time of the request.
count
Type: SystemInt32
The number of compressed values to return. This number must be greater than zero.
forward
Type: SystemBoolean
A value of indicates to begin at the start time and move forward in time. A value of indicates to move backward in time. When moving backward, values will be returned in time descending order.
boundaryType
Type: OSIsoft.AF.DataAFBoundaryType
A value from the AFBoundaryType enumeration that determines how the time and value at the start time is determined.
desiredUOM
Type: OSIsoft.AF.UnitsOfMeasureUOM
The desired unit of measure for the returned values. If , then the values are returned in the unit of measure specified by the associated attribute's DefaultUOM property.
filterExpression
Type: SystemString
A string containing a filter expression. Expression variables are relative to the attribute. Use '.' to reference the containing attribute. A or empty string indicates no filtering. If the attribute does not support the Filters option, the filter will be ignored.
includeFilteredValues
Type: SystemBoolean
Specify to indicate that values which fail the filter criteria are present in the returned data at the times where they occurred with a value set to a "Filtered" enumeration value with bad status. Repeated consecutive failures are omitted.
cancellationToken (Optional)
Type: System.ThreadingCancellationToken
A cancellation token used to abort processing before completion. Passing the default CancellationToken.None will run to completion or until the PIConnectionInfo.OperationTimeOut period elapses.

Return Value

Type: TaskAFValues
Returns a task whose result is an AFValues collection with the recorded values.

Exceptions

ExceptionCondition
NotSupportedException The data reference does not support the this method, or the configured data reference does not support filter expressions and one was provided.
AggregateException Asynchronous methods throw AggregateException on failure which will contain one or more exceptions containing the failure.

Remarks

Note Notes to Callers
This method, property, or class is not available in the legacy .NET 3.5 version of the SDK.

Security note Security Note
You must have ReadData security rights to read a data value.

Note Notes to Callers
This call might use a background task to complete some of its work. See the Threading Overview for some matters to consider when execution transitions to another thread.

Important note Important
Asynchronous data calls in AF SDK attempt to do as much work as possible asynchronously. If no work can be done asynchronously, then the SupportedDataMethods will report that asynchronous calls are not supported. If an attribute uses a Formula or other calculated data reference has any input that supports asynchronous calls, then the attribute will support asynchronous calls. When making an asynchronous data call, input data will be acquired asynchronously when possible or synchronously otherwise. Data calls that require partitioning across versions will always fall back to synchronous calls.

Important note Important
Impersonation of AF SDK asynchronous calls relies on the .NET framework's built-in support for flowing execution context across asynchronous points. When making these calls while impersonating, the thread or runtime must be configured to propagate the impersonation across these asynchronous points (see the SecurityContext documentation for details).

Version Information

AFSDK

Supported in: 3.1.1, 3.1.0, 3.0.2, 3.0.1, 3.0.0, 2.10.11, 2.10.5, 2.10.0, 2.10, 2.9.5, 2.9, 2.8.5, 2.8

See Also

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in