Creating Custom Events

Starting from Visual Basic 2005, you have the ability to define your own events implementing the custom events. They are useful because they provide a kind of relationship with a delegate. Generally custom events are also useful in multithreaded applications. You declare a custom event via the Custom Event keywords combination, supplying the event name and signature as follows:

image

IntelliSense is very cool here, because when you type the event declaration and press Enter, it adds a skeleton for the custom event that is constituted by three members: AddHandler is triggered when the caller subscribes for an event with the AddHandler ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.