A
Armin Zingler
Hi,
I add event handlers to different events of objects of different type. In an
array or arraylist, I want to store the information about which events I
added. Later, I want to process the arraylist and detach all the event
handlers. My problem is that I don't know which information to store. When
removing the handlers in a loop, the most important thing is that I don't
want to distinguish between the different object types and events, so I want
the code to be based on the basic Delegate/MulticastDelegate classes. I have
currently no clue how to do it. Something like:
dim o as new class1
addhandler o.ev1, addressof OnEv1
addhandler o.ev2, addressof OnEv2
...
for each i as Item in al 'al=arraylist, item=new class (see below)
removehandler i.???, i.???
next
Each time I use Addhandler I will create a new Item object and add it to the
arraylist. Though, I don't know what to store in an Item object. I thought
it must be a MulticastDelegate (the event) and a Delegate (the event
handler), but I am not able to store a reference to o.ev1 or o.ev2.
Is it possible at all or do I have to handle each event and object
individually? (btw, reflection is not an option) Thanks in advance.
Armin
I add event handlers to different events of objects of different type. In an
array or arraylist, I want to store the information about which events I
added. Later, I want to process the arraylist and detach all the event
handlers. My problem is that I don't know which information to store. When
removing the handlers in a loop, the most important thing is that I don't
want to distinguish between the different object types and events, so I want
the code to be based on the basic Delegate/MulticastDelegate classes. I have
currently no clue how to do it. Something like:
dim o as new class1
addhandler o.ev1, addressof OnEv1
addhandler o.ev2, addressof OnEv2
...
for each i as Item in al 'al=arraylist, item=new class (see below)
removehandler i.???, i.???
next
Each time I use Addhandler I will create a new Item object and add it to the
arraylist. Though, I don't know what to store in an Item object. I thought
it must be a MulticastDelegate (the event) and a Delegate (the event
handler), but I am not able to store a reference to o.ev1 or o.ev2.
Is it possible at all or do I have to handle each event and object
individually? (btw, reflection is not an option) Thanks in advance.
Armin