Multithreading · Performance · Programming

Common Multithreading Mistakes in C#; Part II

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

Advertisements

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

  1. A great read. Satisfied my deeper dev brain. Working on simple crud line of business apps don’t offer a lot of opportunity to do this kind of development.

    I wonder if you could write something about .NET’s HostingEnvironment.QueueBackgroundWorkItem. Is it related at all to these techniques or is it a higher level of abstraction?

    Like

    1. Hi Joseph, thanks for the kind comments. Sorry to hear that your current work isn’t giving you the mental challenge you seek, but there’s always side projects! :)

      RE HostingEnvironment.QueueBackgroundWorkItem: I’m not an ASP.NET programmer and therefore absolutely not qualified to answer that question, I’m sorry. However a quick scan of MSDN implies that that particular API is a task/futures abstraction, like the TPL, but bespoke for the needs of general web/enterprise development. That would make it a higher level of abstraction and somewhat orthogonal to the ideas discussed in this series, as thread safety and tasks/futures are related but distinct topics.

      Like

    2. HostingEnvironment.QueueBackgroundWorkItem is similar to ThreadPool.QueueBackgroundWorkItem with two exceptions: it’s Task-friendly and it provides a way to signal that the environment is about to shut down (using CancellationToken).

      As xenoprimate mentioned, this is a higher level of abstraction. But if you queue up several background tasks which use some shared state, everything that is described in this blog series is still applicable. Because essentially this method is equal to starting a new thread.

      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