Events and commissioned in-depth understanding

  • Event Publisher:
    • Some pre-defined function pointers, available to subscribers of events
    • In the local publisher suitable place to study these functions pointer to a function, enabling calls to functions provided by the event subscriber
  • Event subscribers: to assign your own function approach function pointer to the event publisher offered
  • Using the Event
    • Delegates provide a similar callback function for each additional subscriber, the publisher needs to provide a delegate object is referenced to provide to subscribers
    • If you use a delegate, you need to define a lot delegate object within an event publisher references to subscribers for each event
    • Callback function pointers list released by the publisher event publisher is actually provided externally
  • C # implement event mechanisms
  1. Publishers define a delegate type
  2. Publishers define an event, and events related to the word delegate defined above
  3. Subscribers produces a delegate instance, and add it to the list of delegates

Guess you like

Origin www.cnblogs.com/xadlriver/p/11670443.html