AFData.UpdateValuesAsync Method (AFValues, AFUpdateOption, AFBufferOption, CancellationToken)
- Last UpdatedNov 18, 2025
- 4 minute read
- PI System
- AF SDK 2024 R2
- Developer
Namespace: OSIsoft.AF.Data
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public Task<AFErrors<AFValue>> UpdateValuesAsync( AFValues values, AFUpdateOption option, AFBufferOption bufferOption, CancellationToken cancellationToken = default )
Public Function UpdateValuesAsync ( values As AFValues, option As AFUpdateOption, bufferOption As AFBufferOption, Optional cancellationToken As CancellationToken = Nothing ) As Task(Of AFErrors(Of AFValue)) Dim instance As AFData Dim values As AFValues Dim option As AFUpdateOption Dim bufferOption As AFBufferOption Dim cancellationToken As CancellationToken Dim returnValue As Task(Of AFErrors(Of AFValue)) returnValue = instance.UpdateValuesAsync(values, option, bufferOption, cancellationToken)
public: Task<AFErrors<AFValue^>^>^ UpdateValuesAsync( AFValues^ values, AFUpdateOption option, AFBufferOption bufferOption, CancellationToken cancellationToken = CancellationToken() )
member UpdateValuesAsync : values : AFValues * option : AFUpdateOption * bufferOption : AFBufferOption * ?cancellationToken : CancellationToken (* Defaults: let _cancellationToken = defaultArg cancellationToken new CancellationToken() *) -> Task<AFErrors<AFValue>>
Parameters
- values
- Type: OSIsoft.AF.AssetAFValues
The values to be written or replaced on the target system. - option
- Type: OSIsoft.AF.DataAFUpdateOption
An enumeration value that specifies how to treat duplicate values. It can also be used to specify that an existing value should be removed. - bufferOption
- Type: OSIsoft.AF.DataAFBufferOption
An enumeration value that specifies buffering option. - 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: 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. |
| ArgumentNullException | The values is . |
| ArgumentException | The values must contain at least one AFValue. |
| InvalidOperationException | The Attribute does not have a data reference configured. |
| NotSupportedException | The data reference does not support this method. |
Remarks
This method requires that the attributes being written, if configured with a data reference, must support the UpdateValues method. This is indicated by having the UpdateValues flag set in the SupportedDataMethods property. The PI Point Data Reference supports UpdateValues for simply configured PI Points.
For the case of attributes which are configuration items, this method (unlike AFAttribute.SetValue) does not require the corresponding AFElement to be checked out or checked in.
If AFBufferOption is set to Buffer, this method requires that the attribute has a configured data reference which supports buffering. This is indicated by having the Buffering flag set in the SupportedDataMethods property. The PI Point Data Reference supports buffering.
| This method, property, or class is not available in the legacy .NET 3.5 version of the SDK. |
| You must have WriteData security rights to write a data value. |
| This method is not supported for attributes that do not have a data reference. Consider using AFListData.UpdateValues. |
| 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. |