Catherine,
I assume that by "raising an event" you mean invoking a delegate? The
following code shows how you can invoke a delegate in unmanaged code:
------------------------------------------------------------------------
#using <mscorlib.dll>
using namespace System;
__delegate void TestEventHandler();
class UnmanagedClass {
public:
void doSomething(TestEventHandler *testEventHandler);
};
void UnmanagedClass::doSomething(TestEventHandler *testEventHandler) {
testEventHandler->Invoke();
}
__gc class ManagedClass {
public private:
void testEventOccurred() {
Console::WriteLine(S"It happened!");
}
};
int _tmain()
{
UnmanagedClass unmanagedClass;
ManagedClass *managedClass = new ManagedClass();
unmanagedClass.doSomething(new TestEventHandler(managedClass,
ManagedClass::testEventOccurred));
return 0;
}
------------------------------------------------------------------------
Catherine Jones wrote:
Dear All
Please help me in the following issue:
how to raise an event from an unmanaged class to a
managed class.
Both classes are in C++ and there should not be any static methods involved
in this implementation.
ie. the event source is an unmanaged class and event receiver should be a
managed class.
Also the event receiver method should not be static.
Thank you very much for your understanding.