By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,384 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,384 IT Pros & Developers. It's quick & easy.

Raise Events from Objects In a Collection?

P: n/a
My application creates a number of objects for monitoring servers. Each
object monitors one server. When an object detects certain conditions in the
server, it should raise an event to notify the parent application (not the
collection object).

I know this has been discussed before, but I can't find a definitive HOWTO
that is current. Can someone point me in the right direction?

--Eric
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
For each of the objects (when declared), use the following code:

Public Sub DeclareObject()

object = new object...
AddHandler object.<the object's event>, AddressOf <the sub that you
wish to call upon the event>
...add to list...

End Sub

You would use RemoveHandler in the same fashion.

Also, to pass back the identity of the object in the list that is
calling the event, simply place a parameter in the event as follows:

Public Class TheObject

Public Event SomeEventToRaise(sender as TheObject)

Public Sub blah()

...
RaiseEvent SomeEventToRaise(me)
...

End Sub

End Class

and then you would put a matching parameter in the target of the
AddHandler so that it would recieve the identity of the object.

Matt

Eric Robinson wrote:
My application creates a number of objects for monitoring servers. Each
object monitors one server. When an object detects certain conditions in the
server, it should raise an event to notify the parent application (not the
collection object).

I know this has been discussed before, but I can't find a definitive HOWTO
that is current. Can someone point me in the right direction?

--Eric

Nov 21 '05 #2

P: n/a
That's good inmformation, thanks. I will try it shortly!

"Matt" <ba*******@hotmail.com> wrote in message
news:qFWDe.10776$Zx3.854@trndny05...
For each of the objects (when declared), use the following code:

Public Sub DeclareObject()
object = new object...
AddHandler object.<the object's event>, AddressOf <the sub that you
wish to call upon the event>
...add to list...
End Sub

You would use RemoveHandler in the same fashion.

Also, to pass back the identity of the object in the list that is calling
the event, simply place a parameter in the event as follows:

Public Class TheObject
Public Event SomeEventToRaise(sender as TheObject)
Public Sub blah()
...
RaiseEvent SomeEventToRaise(me)
...
End Sub
End Class

and then you would put a matching parameter in the target of the
AddHandler so that it would recieve the identity of the object.

Matt

Eric Robinson wrote:
My application creates a number of objects for monitoring servers. Each
object monitors one server. When an object detects certain conditions in
the server, it should raise an event to notify the parent application (not
the collection object).

I know this has been discussed before, but I can't find a definitive HOWTO
that is current. Can someone point me in the right direction?

--Eric

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.