2

I did two sample projects (links to executable code) after watching a tutorial. One Without Event using delegate as property and one With Events. I get the same output when used without events. I can also subscribe/unsubscribe to notification in both cases.

What is the benefit of using event taking my sample code as an example?

lbrahim
  • 3,710
  • 12
  • 57
  • 95
  • Yes.Mentioned thread has answers I was looking for. To summarize for my brains's sake. 1.Controlling access to the delegate (analogous to Field-Property) 2.Event provides more semantics to the class or user using the class 3.Helps with Synchronization in multi-threading – lbrahim Sep 05 '13 at 20:05
  • **IMPORTANT** Another obvious reason I realized was that if I use `delegate` as property then I can mess around with the Invocation List by just assigning (=) it to another method or null perhaps rather than adding (+=) or removing (-=). But `event` will enforce me to add or remove ONLY thus, preserving the Invocation list. – lbrahim Sep 05 '13 at 22:19
  • [Sample Code](http://rextester.com/ZTHBRI54970) to convey my meaning as mentioned above. – lbrahim Sep 05 '13 at 22:30

0 Answers0