protected virtual void OnMBusException(ModBusException.ModBusExceptionCodeEnum Code) { // Make a temporary copy of the event to avoid possibility of // a race condition if the last subscriber unsubscribes // immediately after the null check and before the event is raised. MBusException handler = EventMBusException; ModBusException e = new ModBusException(Code); // Event will be null if there are no subscribers if (handler != null) { // Use the () operator to raise the event. handler(this, e); } }
void MyModbus_EventMBusException(object sender, ModBusException e) { textBox1.Text = e.ModBusExceptionCode.ToString() + "\r\n" + textBox1.Text; }