I've found this useful little pattern browsing the code of the latest Prism drop.
It looks like this:
public event EventHandler
I've never declared events in my code this way. But using this little pattern you can forget about the tedious safety event raising checks and write like in the following line of code:
Updated(null, new AccountPositionEventArgs());
instead of:
EventHandler
if (handler != null)
handler(null, new AccountPositionEventArgs());
I'll remember this great stuff.
Good luck!
Wednesday, 26 March 2008
Safe event pattern
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment