gOPCUAConnector.gAsyncWriteItems Method

Top  Previous  Next


Used to write values to OPC Nodes asynchronously.

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

And because this is an asynchronous method, results comes with an event: gAsyncWriteItemsCompleted


VB syntax

gOPCUAConnector.gAsyncWriteItems(itemsToWrite() As gOPCUAReadWriteObject, transactionID As String)


C# syntax

gOPCUAConnector.gAsyncWriteItems(gOPCUAReadWriteObject[] itemsToWrite, string transactionID) 




Array of ReadWriteObjects that holds OPC NodeIDs and values that you want to write.



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

Used in   gAsyncWriteItemsCompleted  event or to cancel asynchronous operation.


Return Type



C# code example



                //Step1: Create an array of read-write object , assign ItemIDs and assign values you want to write

                GelecekCommon.gOPCUAReadWriteObject[] read_write_objs = new GelecekCommon.gOPCUAReadWriteObject[2];


                for (int i = 0; i < read_write_objs.Length; i++)


                    read_write_objs[i] = new GelecekCommon.gOPCUAReadWriteObject();


                read_write_objs[0].NodeID = txtNodeID1.Text;

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


                read_write_objs[1].NodeID = txtNodeID2.Text;

                read_write_objs[1].Value = txtValue2.Text; //Be careful, Text should be able to convert to data type of OPC Node


                //Step2: Run gAsyncWriteItems method  

                GelecekCommon.gOPCUAStatusCode function_result = gOPCUAConnector1.gAsyncWriteItems(read_write_objs, txtTransactionID.Text);


                //Step3: Check function result to be sure about a successfull writing

                //For a successfull write, function result should be "OK" 

                txtFunctionResult.Text = function_result.ToString();



            catch (Exception ex)