473,387 Members | 1,476 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,387 software developers and data experts.

Urgent help needed! Raising events!

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.
Nov 16 '05 #1
2 1972
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.


Nov 16 '05 #2
Thanx Bart, I got an idea from your code.
Thanx a lot for your time and understanding!

"Bart Jacobs" <ba*********@student.kuleuven.ac.be> wrote in message
news:10***************@seven.kulnet.kuleuven.ac.be ...
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.

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: choksi | last post by:
Hello All I am running PHP5.0.2 over apache 1.3.29 and openssl-0.9.7d on a Debian Linux and with a fake (internal)ip. Php Configure command './configure' '--with-apxs=/www/bin/apxs'...
10
by: Tony Archer | last post by:
Gentlemen, your urgent help is needed in solving a STRANGE problem. I have two servers a dev box, and a production box. On the dev box everything works fine, in production it hoses: One of...
1
by: Tony Archer | last post by:
(Forgive the dupicate post, I had left out the OS Version out of the prior post.) Gentlemen, your urgent help is needed in solving a STRANGE problem. I have two servers a dev box, and a...
0
by: felix_william | last post by:
Attention=3A Dear friend=2C REQUEST FOR BUSINESS RELATIONSHIP OF GREAT PROFITS I am HON=2E =28DR=2E=29 Felix William=2C the Director of Procurement and Contract Award at the Nigerian National...
12
by: Vibhajha | last post by:
Hi friends, My sister is in great problem , she has this exam of C++ and she is stuck up with some questions, if friends like this group provides some help to her, she will be very grateful....
4
by: Random | last post by:
The way I've built my page is to take the user through a multi-form process, only rendering those controls that are needed for each section. The ViewState is working the way I want it to,...
7
by: meenasamy | last post by:
Hi all, i need to create a function that takes three parameters( Original currency, needed currency, amount) i need to convert from the original currency to the needed currency the amount and...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
2
by: Preetam Pattanashetty | last post by:
Hi I am learning ASP.NET using C#. I am able to run .aspx files on local system, but when I load them to the server, I get the "Server Error in '/' Application" error. I have tried to configure the...
0
by: Christopher | last post by:
Urgent Help Needed: The EPVH-1.1 Visual Hull Library. Dear All, I am a student doing research in computer vision. The EPVH-1.1 Visual Hull Library will really help a lot in my research. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.