473,320 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 1026
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dave A | last post by:
I have two events in a form that I am passing. One is to a javascript function, the other is to the same .asp page only with another action to show different data. Onchange is calls the...
2
by: Kyzer | last post by:
Hi all, I have created a class which contains many TShapes, TLabels and TPanels. What I want to be able to do is when creating this class, is passing in a pointer to OnMouseDown and OnMouseUp...
3
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing...
6
by: Max | last post by:
Last time I tried to explain this on another forum it didn't go too well, so I'll try my best and if you know what I'm talking about then please tell me how to do this. I have a class, inside I...
3
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following...
30
by: Burkhard | last post by:
Hi, I am new to C# (with long year experience in C++) and I am a bit confused by the language construct of events. What is it I can do with events that I cannot do with delegates? At the moment...
1
by: olrt | last post by:
Hello, I have designed a WebService with the following method : public DbAppAnswer GetDs(DbAppRequest request) DbAppRequest and DbAppAnswer are defined as :
1
by: GilligansGhost | last post by:
The biggest problem I have is that Events confuse me. I need an event to fire from a button to a TestClass() activeating a method Proc() and then i need the test class to fire a string to append to...
2
by: Israel | last post by:
It seems like there should be a way to pass events around like delegates but on the other hand they’re sort of special delegates because the only one allowed to invoke them is the owner of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.