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

Passing events to another class

P: n/a
Is there any way to pass an array of events to another class? My idea is to
pass an array of events that will be fired by a managed object whenever a
manager class should update itself. The manager class would get the array of
events from a managed object when the managed object is associated with the
manager (in order to add event handlers) and then again when the managed
object is disassociated with the manager (in order to remove the event
handlers).

Thanks for any help.
Lance

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Lance,

I think a event is kind of delegate which is also known as callback
machensim.
The class(B) out of the classobject (A), add event handler of A, that is
similar with store a function pointer in the A's callback collection.
When the B call some method of A, the A's method will call the function
pointer that B assigned to it before.

So I think the manager class just needed to pass the classobject(A)'s
reference and then call the fireevent's method in A.

[pseudocode]
class classobject
{
event TestEvent
void FireTestEvent()
{
raiseevent TestEvent
}
}

class managedclass
{
void FireObjectEvent(object o)
{
o.FireTestEvent
}
}

If I have any misunderstanding, can you please describe your scenario more
detailed.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.