Chapter 14. Delegates and Events

In This Chapter

A delegate is a type safe function pointer. Although the idea of a delegate is not difficult to grasp, how it is implemented, what additional functionality has been added, and just how universally it is applied and used are all topics that deserve much more discussion.

The Windows APIs are becoming more asynchronous in nature. For example, when a user clicks on a button in your application, notification of this event is undoubtedly happening asynchronous to your application. Much of the APIs dealing with I/O can be greatly streamlined by utilizing an asynchronous model. Chapters 12, “Networking,” and 13, “Remoting,” have already utilized events and delegates to simplify and enhance the overall usability of distributed applications. Before the CLR, it was cumbersome and error prone to define callback functions required as part of an event-driven model. Somehow you need to give the software that is providing a service for you a definition of how and where you would like to be notified when the service is complete. This chapter discusses what is new and different about delegates as opposed to more traditional forms of notification specification. It also covers events, which are used extensively not only in the framework, but also add a good deal of functionality to delegates.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.114.142