Yes. Apparently so.
According to dotPeek , here is the code for add
and remove
handlers for Application.ThreadException:
public static event ThreadExceptionEventHandler ThreadException { add { System.Windows.Forms.IntSecurity.AffectThreadBehavior.Demand(); Application.ThreadContext threadContext = Application.ThreadContext.FromCurrent(); lock (threadContext) threadContext.threadExceptionHandler = value; } remove { Application.ThreadContext threadContext = Application.ThreadContext.FromCurrent(); lock (threadContext) threadContext.threadExceptionHandler -= value; } }
Note that in the remove
handler, it uses -=
as expected, but in the add
handler it just uses =
? You think it should be +=
, but it looks like it is not.
So, when you use the +=
operator to add a new event handler (which translates to calling the add
handler), WinForms actually replaces the existing handler, rather than adding to it.
Looks like a mistake, simple and simple. If you write this on Connect , post the link here so that others can vote for it.
source share