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 9139351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:22:34+00:00 2026-06-17T09:22:34+00:00

I was looking at these questions from 2009: C# Events and Thread Safety I

  • 0

I was looking at these questions from 2009:
C# Events and Thread Safety

I also looked at Eric Lippert’s blog post on the same topic:
http://blogs.msdn.com/ericlippert/archive/2009/04/29/events-and-races.aspx

The problem seems to boil down to, in a multithreaded environment you will occasionally encounter the situation where a different thread has unregistered the delegate between your thread’s (thread A) ‘if’ statement and ‘call delegate’ statement.

As I was reading, this question came to my mind: If the alternates seem to be a choice between either a race condition or a thrown exception, then why not just wrap it in a try/catch block and not worry about either? If you catch the nullReferenceException, just ignore it in the catch block (simply to suppress the exception) and move on.

Now, I understand Eric Lippert and John Skeet know a little bit about C#, multithreading, and delegates, so could someone please take a moment and explain what I am missing here?

  • 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. Editorial Team
    Editorial Team
    2026-06-17T09:22:35+00:00Added an answer on June 17, 2026 at 9:22 am

    Maybe I understand you wrong, but you can’t catch every race conditions with just try-catch. See the code below

    int count = 0;
    for (int i = 0; i < 1000; i++) 
                Task.Factory.StartNew(()=>count++,TaskCreationOptions.LongRunning);
    Console.WriteLine(count);
    

    this may print other that 1000 when run several times.

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

Sidebar

Related Questions

I need to order some onReady calls, I was looking at these questions here
I'm putting together my first web page, and I've been looking at these FTP
Im looking to make my own implementation of these Identicons or Gravatars found here
I'm looking for a tutorial explaining how to work with these 3 technologies, found
I'm looking for a Vim plugin that can do these kind of thing. Let's
I am looking for something very close to an application server with these features:
I was recently looking to practice utilizing dictionaries in python and stumbled across these
Looking for sql to get distinct names and count of those names from a
I'm looking for a way of getting input from the software keyboard from a
I am looking at such previous questions as: https://stackoverflow.com/questions/98334/creating-a-java-servlet-web-application How many actions should a

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.