Weak Events in C#
Un très bon article sur CodeProject décrivant les events C#... il propose plusieurs alternatives au événements standard (toto.eventX += some event handler).
Table of contents
- Introduction
- What exactly are events?
- Part 1: Listener-side weak events
- Solution 0: Just deregister
- Solution 1: Deregister when the event is called
- Solution 2: Wrapper with weak reference
- Solution 3: Deregister in finalizer
- Solution 4: Reusable wrapper
- Solution 5: WeakEventManager
- Part 2: Source-side weak events
- Solution 0: Interface
- Solution 1: WeakReference to delegate
- Solution 2: object + Forwarder
- Solution 3: SmartWeakEvent
- Solution 4: FastSmartWeakEvent
- Suggestions
Lien :
http://www.codeproject.com/KB/cs/WeakEvents.aspx