__event alternative

The following page : http://msdn2.microsoft.com/en-us/library/6f01ek09.aspx

says that __event -based event handling is deprecated. In that case, what is the best way to do event handling

I have a class HWClass, that talks to a hardware device. Several other classes need to read from this hardware device. However, the reading is asynchronous and HWClass needs to notify the calling object if the reading process is finished.

(Bt the way, this is native C++ and not CLR)

Thanks!


Answer this question

__event alternative

  • Nasser Yacout

    I can not see how the __event keyword would help you
    Also I can noit see that it is deprectated. Also it has nothing to do with parallel operations, like asynchron reading or similar things.

    Place you I/O (reading the hardware device) into a second thread. Use a Win32 Event to wait for the thread to finish its job. If the worker thread is done with reading it should raise the event (SetEvent).



  • Mr G

    These links hit the spot. THANKS A LOT!

  • JulieAnne

  • BalajiB


    In the second paragraph of the link I gave:

    ==
    Event handling is also supported for native C++ classes (C++ classes that do not implement COM objects), however, that support is deprecated and will be removed in a future release.
    ==

    i was familiar with the old-style Win32 events. I just saw how convenient and clean it was to use __event, __hook and __unhook and wondered why it was deprecated.

    Thanks :)



  • __event alternative