Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / December 2003

Tip: Looking for answers? Try searching our database.

Urgent help needed! Raising events!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Catherine Jones - 10 Dec 2003 04:59 GMT
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.
Bart Jacobs - 10 Dec 2003 19:55 GMT
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;
}
------------------------------------------------------------------------

> Dear All
> Please help me in the following issue:
[quoted text clipped - 6 lines]
> Also the event receiver method should not be static.
> Thank you very much for your understanding.
Catherine Jones - 11 Dec 2003 11:28 GMT
Thanx Bart, I got an idea from your code.
Thanx a lot for your time and understanding!

> Catherine,
>
[quoted text clipped - 44 lines]
> > Also the event receiver method should not be static.
> > Thank you very much for your understanding.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.