Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 108727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:57:26+00:00 2026-05-11T01:57:26+00:00

I have come across what must be a common problem. When I have an

  • 0

I have come across what must be a common problem. When I have an event which may be subscribed to by several different classes, an exception thrown by one of these classes will kill the callback chain; as I do not know a priori in what order the callback is carried out, this can result in unpredictable state changes for some classes and not for others.

In the bible (CLR via C#, I am using C# 2.0) there is a short paragraph about using MulticastDelegate.GetInvocationList to get around this, but nothing more. So my question is: what is the best way to deal with this? Do I have to use MulticastDelegate.GetInvocationList every time I have an event?? Or do I need to enclose all methods which may be called as part of the delegate chain in some kind of rollback mechanism? Why are all these options so complicated in comparison to the simple event/delegate model which is so easy to use in C#? And how can I use the simple way without ending up with corrupted state?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:57:27+00:00Added an answer on May 11, 2026 at 1:57 am

    If you simply invoke a delegate, it will call all the target methods in order. You need to use GetInvocationList if you want to execute them individually – for example:

    • to check Cancel after each
    • to capture the return value of each
    • to continue after failure of an individual target

    As for the best way to use it: how do you want it to behave? It isn’t clear to me… for example, this might suit an extension method quite well:

    static void InvokeIgnoreErrors(this EventHandler handler,         object sender) {     if(handler != null) {         foreach(EventHandler subHandler in handler.GetInvocationList()) {             subHandler(sender, EventArgs.Empty);         }     } } 

    Then you can just call myHandler.InvokeIgnoreErrors(this); (for example).

    Another example might be:

    static bool InvokeCheckCancel(this CancelEventHandler handler,         object sender) {     if(handler != null) {         CancelEventArgs args = new CancelEventArgs(false);         foreach(CancelEventHandler subHandler in handler.GetInvocationList()) {             subHandler(sender, args);             if(args.Cancel) return true;         }     }     return false; } 

    which stops after the first event requests cancellation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 262k
  • Answers 262k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You have to understand that shared pointers are implemented using… May 13, 2026 at 11:44 am
  • Editorial Team
    Editorial Team added an answer Yes, though it is far better to override getViewTypeCount() and… May 13, 2026 at 11:44 am
  • Editorial Team
    Editorial Team added an answer If we could convert the 2 conditions for A and… May 13, 2026 at 11:44 am

Related Questions

My company is looking to replace all websites in the group with a new
I'm trying to learn dependency injection and have come across a problem, when unit
I'd like to work on a project, but it's a little odd. I want
I have recently come across a situation where code is dynamically loading some libraries,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.