代码改变世界

随笔档案-2012年04月

.NET基础扩展系列-事件的实现原理

2012-04-09 17:41 by 爱车龟速兔, 797 阅读, 收藏,
摘要: CLR VIA C#这本书中, 写到了事件的实现原理, CLR是使用委托字段来实现事件的:// 1. A PRIVATE delegate field that is initialized to null static EventHandler<EventArgs> NewMail = null;// 2. A PUBLIC add_Xxx method (where Xxx is the Event name) // Allows methods to register interest in the event. static void add_NewMail(EventHa 阅读全文