有人可以解释这段代码有什么问题吗?当我打电话给 mco 时,此事件不会触发。
private ModiconComunications.ModiconComObject withEventsField_mco = new ModiconComunications.ModiconComObject();
private ModiconComunications.ModiconComObject mco
{
get { return withEventsField_mco; }
set
{
if (withEventsField_mco != null)
{
withEventsField_mco.GetDataReturn -= mco_GetDataReturn;
}
withEventsField_mco = value;
if (withEventsField_mco != null)
{
withEventsField_mco.GetDataReturn += mco_GetDataReturn;
}
}
}
当我调用以下行时,它应该触发事件 mco_GetDataReturn,但是它不会。我做错了什么?
mco.GetData(ModiconComunications.ModiconComObject.GetDataType.READ_MODICON_HREGS, 11421, 9, 0);