Advanced C# · Multithreading · Performance

Common Multithreading Mistakes in C#; Part I

This content has permanently moved to http://benbowen.blog/post/cmmics_i/

Advertisements

4 thoughts on “Common Multithreading Mistakes in C#; Part I

  1. Hello, thanks for the series of articles about multithreading, very helpful!

    Noticed a subtle mistake:

    In this example:

    ReactorEventDispatcher.HeatCritical += async () => {
    var triggerShutdownTask = Task.Run((Action) ReactorEventDispatcher.TriggerSafetyShutdown);

    OtherLongRunningSafetyCode();
    
    await triggerShutdownTask;
    

    };

    you should have written:
    triggerShutdownTask.Wait();
    to achieve a deadlock,
    otherwise:
    await triggerShutdownTask
    will return execution to calling context with no problems.

    Like

    1. Hi Alexander, thanks for the correction. I’m currently in the process of migrating the blog to a new platform and once that is complete I’ll write up an edit regarding your comment.

      Thanks, and merry Christmas :)

      Like

Add a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s