R
Roy Chastain
I have a case where I think I need to use a Managed Virtual Event.
I have a base class that will fire the event. That class is private
to the assembly. The receiving class in another assembly can only
hook the event in the derived classes.
I have something that compiles but it does not work (the event handler
never gets called) and I really don't even have an idea as to what to
do to fix it.
All the examples dealing with virtual events appear to be very
incomplete and they use the __delegate keyword. I would really rather
use the method syntax if that is possible. If it is not possible to
use the method syntax, does it matter where I put the __delegate
declaration?
Assembly1
private __gc BaseClass {
public:
__event virtual void MyEvent (UInt32 event_value);
void FireingFunction (void)
{ MyEvent(3); }
};
public __gc DerivedClass1: public BaseClass {
__event virutal void MyEvent (UInt32 event_value);
}
Assembly2
public __gc ReceiverClass {
public:
void OnMyEvent (UInt32 event_value);
void SomeFunction (void)
{
__hook(&DerivedClass1::MyEvent,instance_of_DerivedClass1,&ReceiverClass::OnMyEvent);
}
Thanks for the help
I have a base class that will fire the event. That class is private
to the assembly. The receiving class in another assembly can only
hook the event in the derived classes.
I have something that compiles but it does not work (the event handler
never gets called) and I really don't even have an idea as to what to
do to fix it.
All the examples dealing with virtual events appear to be very
incomplete and they use the __delegate keyword. I would really rather
use the method syntax if that is possible. If it is not possible to
use the method syntax, does it matter where I put the __delegate
declaration?
Assembly1
private __gc BaseClass {
public:
__event virtual void MyEvent (UInt32 event_value);
void FireingFunction (void)
{ MyEvent(3); }
};
public __gc DerivedClass1: public BaseClass {
__event virutal void MyEvent (UInt32 event_value);
}
Assembly2
public __gc ReceiverClass {
public:
void OnMyEvent (UInt32 event_value);
void SomeFunction (void)
{
__hook(&DerivedClass1::MyEvent,instance_of_DerivedClass1,&ReceiverClass::OnMyEvent);
}
Thanks for the help