Can someone explain what is wrong with this code? This event will not fire when I make a call to 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;
}
}
}
When I call the below line, it should fire off the event mco_GetDataReturn, however, it does not. What have I done incorrectly?
mco.GetData(ModiconComunications.ModiconComObject.GetDataType.READ_MODICON_HREGS, 11421, 9, 0);
Well, you initial withEventsField_mco, the one that is created by this line:
Doesn’t get it’s event handlers hooked up. Unless you are doing that in the constructor.