gOPCUAConnector.gAsyncWriteOneItem Method

Top  Previous  Next


Used to write value to a single OPC Node asynchronously.

This method does not freeze your application like a synchronous method.

And because this is an asynchronous method, result comes with an event: gAsyncWriteOneItemCompleted


VB syntax

gOPCUAConnector.gAsyncWriteOneItem(itemToWrite As gOPCUAReadWriteObject, transactionID As String)


C# syntax

gOPCUAConnector.gAsyncWriteOneItem(gOPCUAReadWriteObject itemToWrite, string transactionID)




ReadWriteObject that holds OPC NodeID and value that you want to write.        



Transaction id is ID of asynchronous operation, a unique string.

Used in   gAsyncWriteOneItemCompleted  event or to cancel asynchronous operation.


Return Type



C# code example



                //Step1: Create a read-write object , assign ItemID and assign value to write

                GelecekCommon.gOPCUAReadWriteObject read_write_obj = new GelecekCommon.gOPCUAReadWriteObject();

                read_write_obj.NodeID = txtNodeID1.Text;

                read_write_obj.Value = txtValue1.Text;  //Be careful, Text should be able to convert to data type of OPC Node


                //Step2: Run gAsyncWriteOneItem method 

                GelecekCommon.gOPCUAStatusCode function_result = gOPCUAConnector1.gAsyncWriteOneItem(read_write_obj, txtTransactionID.Text);


                //Step3: Check function result. For a successfull write, function result should be "Good"

                txtFunctionResult.Text = function_result.ToString();



            catch (Exception ex)