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 TestEventHandle r();
class UnmanagedClass {
public:
void doSomething(Tes tEventHandler *testEventHandl er);
};
void UnmanagedClass: :doSomething(Te stEventHandler *testEventHandl er) {
testEventHandle r->Invoke();
}
__gc class ManagedClass {
public private:
void testEventOccurr ed() {
Console::WriteL ine(S"It happened!");
}
};
int _tmain()
{
UnmanagedClass unmanagedClass;
ManagedClass *managedClass = new ManagedClass();
unmanagedClass. doSomething(new TestEventHandle r(managedClass,
ManagedClass::t estEventOccurre d));
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.