JayBaz points out something that is worth keeping in mind about events: they can be subject to race conditions in multi-threaded scenarios. In VS 2002 and VS 2003, you’ll need to do what the C# folks do and handle the race condition yourself:
Event Moved(ByVal x As Integer, ByVal y As Integer)
Sub Move(ByVal x As Integer, ByVal y As Integer)
Dim temp As MovedEventHandler = Me.MovedEvent
If Not temp Is Nothing Then
(The names “xEventHandler” and “xEvent” are automagically generated names – the first is the delegate type of the event and the second is the hidden field generated to hold the event delegate.)
In Whidbey, however, we’ve changed the code generation for RaiseEvent so that this will be done automatically for you. We work hard so you don’t have to!