Native C++ Events Are Broken 
Author Message
 Native C++ Events Are Broken

A while back I posted a report on what seems to be a problem with native
events and the event_source attribute provider.  The problem is that if you
have an event-firing class like so:

    class EventSource
        EventSource (void);

        __event void EventFoo (void);

the event_source attribute provider will inject a data member called
'__eventHandlerList_EventSource_EventFoo' into the class, and this data
member must be initialized to NULL in the constructor(s), or else any
attempt to fire the event will likely result in an exception.  Under certain
very common circumstances (look up the thread for details), the attribute
provider fails to initialize the event handler list to NULL, and under those
circumstances firing the event results in an exception.  Users of this
feature have no alternative but to dirty their code by manually initializing
the injected data member to NULL.

I've received private e-mails from others who have encountered this bug, but
regretably nobody from Microsoft responded to the thread.  It would be
reassuring to hear some acknowledgement that this issue will be addressed in
a future service pack.

Also, I believe that there is a doc bug at
/vcconIntroductionToUnifiedEventModel.asp when the example code says that
for native C++ classes the event_source attribute is optional.  In my
experience it is not optional.


Thu, 10 Mar 2005 15:52:26 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Native C++ Events Are Broken

2. Native C++ Events Are Broken

3. Is THINK C 5.0 broken, or am I?

4. event_source(native) not injecting event initialization code into constructor always

5. lint on Altos 2000 is BROKE BROKE BROKE!

6. Help a Newbie at Visual C++ (I am not a newbie at C++)

7. Event interface over the internet - am I INSANE?

8. Passing an __event in native C++

9. Using __event in native C++

10. no Intellisense with mixed Managed/Native C++

11. Visual C++ 7 supporting non .NET / Native code?

12. A couple of Win32 native C++ only MSVC7 questions


Powered by phpBB® Forum Software