Chapter 3 demonstrated how events are supported in Visual Basic .NET. There is no question whether we need events, event handlers, and delegates ”Windows is an event-based operating system. The question is whether or not the event model should be accessible to Visual Basic .NET programmers. The answers is a resounding yes.

Visual Basic .NET supports visually associating events and handlers at design time. It also supports associating events and handlers programmatically. VB6 did not support the underlying mechanism for the event model: function pointers (procedural types).

Visual Basic .NET has complete access to the event model and the underlying technology. In this chapter you learned how to associate event handlers with events visually at design time and programmatically at runtime, and how to use function pointers. Function pointers are concealed in classes called delegates in an internal list. As you learned in this chapter, delegates are an evolution of raw function pointers. Because delegates are classes, they have the ability to do more than just store the address of a function. Delegates support storing the addresses of multiple functions and invoking all those functions, as well as determining when no function is available.

Events, event handlers, and delegates are critical to basic Windows programming because they support how Windows fundamentally works. Additionally, delegates support some advanced idioms and are beneficial for new features like multithreading.

Visual Basic. NET Power Coding
Visual Basic(R) .NET Power Coding
ISBN: 0672324075
EAN: 2147483647
Year: 2005
Pages: 215
Authors: Paul Kimmel © 2008-2017.
If you may any questions please contact us: