I have a custom control that derives directly from CheckedListBox. If the CheckedListBox subscribes to its own event (ItemCheck for example) and the user of the control also subscribes to it, does the control's event trigger first before the user's?

I read on MSDN that if multiple subscribers subscribe to an event, they are triggered synchronously, but I wasn't sure if that applied in this situation or not. I understand if there are multiple handlers for one event, but not sure about this one, if the event handlers occured synchronously on the control first and THEN the user's events are triggered synchronously.

Any ideas? I've tested it (kinda) with messageboxes and they always seem to trigger in the same order (but that doesn't mean it always will) with the control's event triggering first, and the form's event handlers triggering afterwards.

Not sure, but can you test it by temporarily putting a MessageBox in each handler to see which one fires first?

I tried that, and it always triggers in the same order, but I'm worried that it could just be a coincidence since they are supposed to execute synchrously.

Could try a message box displaying a datetime down to milliseconds to see which executes first? Should be a slightly noticeable difference in the millisecond portion of the time?

You could also handle both events and make each one call the same (separate ) method to do what you want.
Does this have to do with your new thread where setting the checkedListBox1.CheckOnClick = true;
could solve it?


No that's a different issue, this one involves if an item is checked, a stack object must be updated with some data, and I would like to make sure that the stack is updated BEFORE any user code is executed.

Order example:

  1. User checks item
  2. ItemCheck event is triggered
    A. Since both the control itself and the user using the control subscribe to the ItemCheck event, I would like to make sure the order is as follows:
  3. Stack is updated with data
  4. User event code is executed

If 3 and 4 are reversed, and the user code needs to access the information in that stack, they could be provided with incorrect data.

Also, when I say "user" I mean the programmer using the control on a form, not a end-user of the software product.

I think internally the delegates that subscribe to events are held in a list. Therefore they are fired in the same order as they are added, from start to finish (or maybe finish to start but almost certainly 1 of the 2). If you are really worried, write a program that simulates hundreds of event subscribers and save in a list the order they are fired. Then run an analysis on this data to see if is consistent.

Hey that's a good idea!

I think I'll do that!