AFDataReference.ReplaceValuesAsync Method (AFTimeRange, AFValues, AFBufferOption, CancellationToken)
- Last UpdatedNov 18, 2025
- 3 minute read
- PI System
- AF SDK 2024 R2
- Developer
This method removes existing data within the specified AFTimeRange and
inserts the specified values on the target system using the configured data reference.
Namespace: OSIsoft.AF.Asset
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public virtual Task<AFErrors<AFValue>> ReplaceValuesAsync( AFTimeRange timeRange, AFValues values, AFBufferOption bufferOption, CancellationToken cancellationToken )
Public Overridable Function ReplaceValuesAsync ( timeRange As AFTimeRange, values As AFValues, bufferOption As AFBufferOption, cancellationToken As CancellationToken ) As Task(Of AFErrors(Of AFValue)) Dim instance As AFDataReference Dim timeRange As AFTimeRange Dim values As AFValues Dim bufferOption As AFBufferOption Dim cancellationToken As CancellationToken Dim returnValue As Task(Of AFErrors(Of AFValue)) returnValue = instance.ReplaceValuesAsync(timeRange, values, bufferOption, cancellationToken)
public: virtual Task<AFErrors<AFValue^>^>^ ReplaceValuesAsync( AFTimeRange timeRange, AFValues^ values, AFBufferOption bufferOption, CancellationToken cancellationToken )
abstract ReplaceValuesAsync : timeRange : AFTimeRange * values : AFValues * bufferOption : AFBufferOption * cancellationToken : CancellationToken -> Task<AFErrors<AFValue>> override ReplaceValuesAsync : timeRange : AFTimeRange * values : AFValues * bufferOption : AFBufferOption * cancellationToken : CancellationToken -> Task<AFErrors<AFValue>>
Parameters
- timeRange
- Type: OSIsoft.AF.TimeAFTimeRange
The bounding time range for replacement of the existing values. - values
- Type: OSIsoft.AF.AssetAFValues
The replacement values to be written on the target system. If an empty AFValues then existing data within the specified AFTimeRange will be deleted. The timestamp of AFValue in values must be within the specified AFTimeRange. - bufferOption
- Type: OSIsoft.AF.DataAFBufferOption
An enumeration value that specifies buffering option. - cancellationToken
- 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: TaskAFErrorsAFValueReturns a task whose result is if there are no errors. Otherwise the result is an AFErrorsTKey instance containing error information.
Exceptions
| Exception | Condition |
|---|---|
| AggregateException | Asynchronous methods throw AggregateException on failure which will contain one or more exceptions containing the failure. |
| InvalidOperationException | The Attribute does not have a data reference configured. |
| NotSupportedException | The data reference does not support this method. |
Remarks
| 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. |