Should I Use Events?

后端 未结 2 452
名媛妹妹
名媛妹妹 2021-01-15 17:57

Hi everyone I need a advice, I\'m developing a desktop application (Winform) using C#, I have a Form and I have a separated class named OPC (other file)

This is s

2条回答
  •  迷失自我
    2021-01-15 18:18

    There are two ways to get data from an OPC server: read directly or use the DataChange event. the choice is up to you and one or the other cannot be described as "best practice". If your question is just about implementation then I can tell you that you're missing " Handles ConnectedGroup.DataChange " on the end of your ConnectedOPCGroup_DataChange sub. Your OPCAutomation library will generate the event, you just have to handle it.

    To address the second part of your question, it would be best practice to have your OPC client class separate from your main form.

提交回复
热议问题