gOPCClassicConnector.gAsyncWriteOneItem Method

Top  Previous  Next


Used to write value to a single OPC Item 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

gOPCClassicConnector.gAsyncWriteOneItem(itemToWrite As gOPCClassicReadWriteObject, transactionID As String)


C# syntax

gOPCClassicConnector.gAsyncWriteOneItem(gOPCClassicReadWriteObject itemToWrite, string transactionID)




ItemID of OPC Item 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.gOPCClassicReadWriteObject read_write_obj = new GelecekCommon.gOPCClassicReadWriteObject();

                read_write_obj.ItemID = txtItemID1.Text;

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


                //Step2: Run gAsyncWriteOneItem method 

                GelecekCommon.gOPCClassicFunctionResult function_result = gOPCClassicConnector1.gAsyncWriteOneItem(read_write_obj, txtTransactionID.Text);


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

                txtFunctionResult.Text = function_result.ToString();



            catch (Exception ex)