471,624 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,624 software developers and data experts.

Passing events to another class

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
1 979
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.

Similar topics

7 posts views Thread by Dave A | last post: by
3 posts views Thread by Simon Harvey | last post: by
30 posts views Thread by Burkhard | last post: by
2 posts views Thread by Israel | last post: by
1 post views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
1 post views Thread by ZEDKYRIE | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.