3

I have subscribed to an event using lambda to add a parameter so i dont ont have one eventhandler to execute the code, but how can i unsubscribe to this:

Subscribe:

value.rZone1.onValueChanged += (sender, e) => rZone_onValueChanged(sender, e, 1);

Eventhandler:

void rZone_onValueChanged(IHoldingRegisterBit sender, HoldingRegisterBitValueChangedEventArgs e, int ZoneID)
            {

            }

Unsubscribe: ?????

Jeffnl
  • 261
  • 1
  • 4
  • 21
  • I dont think it is a duplicate, how would i send that int with the eventhandler, if i create a delegate like that? – Jeffnl Apr 18 '14 at 14:08
  • @Jeff The same way you would if you used a lambda; the whole point of the answer is simply to maintain a reference to the lambda, that's all. – Servy Apr 18 '14 at 14:09
  • @Servy, Could you show me how to do this, with keeping one end function and add parameters? – Jeffnl Apr 18 '14 at 14:26
  • You do it exactly as you are now, you just hold onto a reference to the lambda. – Servy Apr 18 '14 at 14:27

0 Answers0