Event handling in VC++ 2005 .NET

B

Ben

Hi

I'm trying to setup a project that uses events. I'm creating a windows
forms based application.

The application interfaces to a DLL that controls a piece of external
hardware, whenever an action occurs on the hardware it needs to signal
my application.

The DLL instructions tell me to use CreateEvent to make the event, I
then pass the event handle to the DLL. This side of things seems to
work correctly and comes back with no errors.

What I'm having trouble with is how to tell the application to execute
this event. The event needs to read the hardware and then return to
the main program.

I could use a timer and continually poll the hardware but as the
hardware could signal at any time there is the danger I wouldn't be
able to pick up the messages quickly enough.

When an action is required the DLL uses SetEvent to signal the app.

My event creation code is:
(this is performed inside a button control on Form1)
HANDLE hGlobalLDVEvent;
hGlobalLDVEvent=CreateEventW(NULL,FALSE,FALSE,TEXT("LDVEVENT"));
hGlobalLDVEvent=OpenEventW(EVENT_ALL_ACCESS,FALSE,TEXT("LDVEVENT"));

this returns with 0x268 which I believe this the event is properly
created?

What do I need to do now?

Thanks for your help

Ben
 
B

bruce barker

winnt events are really event flags (a single variable). to be notified of
when an event value changes, use WaitForSingleObjectEx or
WaitForMutilpleObjectsEx (if you have more than 1 event).


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,196
Latest member
ScottChare

Latest Threads

Top