gOPCClassicConnector.gAsyncWriteItems Method

Top  Previous  Next


Used to write values to OPC Items 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

gOPCClassicConnector.gAsyncWriteItems(itemsToWrite() As gOPCClassicReadWriteObject, transactionID As String)


C# syntax

gOPCClassicConnector.gAsyncWriteItems(gOPCClassicReadWriteObject[] ItemsToWrite, string transactionID)




Array of ItemIDs of OPC Items that you want to write to.



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.gOPCClassicReadWriteObject[] read_write_objs = new GelecekCommon.gOPCClassicReadWriteObject[2];


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


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


                read_write_objs[0].ItemID = txtItemID1.Text;

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


                read_write_objs[1].ItemID = txtItemID2.Text;

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


                //Step2: Run gAsyncWriteItems method  

                GelecekCommon.gOPCClassicFunctionResult function_result = gOPCClassicConnector1.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)