PostSharp Threading Pattern Library

Thread Safety

Make your C# or VB applications thread-safe without rewriting them.

Starting new threads and tasks in .NET languages is simple, but ensuring that objects are thread-safe is not. Choose the threading models that you want and have the built-in verification detect errors in your code before they cause random data races

  • Decreased Complexity
  • Faster feedback
  • Take control

Address threading with machine-verified models.

Reduce complexity

Higher abstraction – Don’t get lost in the details of threading code. Raise the level of abstraction by applying thread safety models with attributes.

Design and implement – Choose thread-safety patterns when designing your application. Translate that design into a functioning code artifact easily and quickly.

Free up your brain – With prebuilt threading models your most experienced developers are free to work on other hard problems while any developer on the team can accurately and confidently deal with threading.

Thread Dispatching – A simple attribute allows you to easily dispatch work to background threads or to the UI.

Fail fast, fail sooner

Model validation – Once you choose a model, PostSharp will ensure that you are not breaking the rules. Get deterministic build-time or run-time errors instead of risking data races.

Make more of your unit tests – With randomness removed, even single-threaded unit tests will expose most threading issues.

Deadlock detection – Deadlocks are hard to diagnose and will frustrate users more than a controlled crash. Avoid the “Not Responding” situation and instead receive a detailed exception that outlines the stack trace for each thread involved.

You’re in the driver’s seat

Immutable
Freezable
Reader/Writer Synchronized
Synchronized
Actor
Thread Affine

Your choice – There are several valid approaches to thread safety. We realize there is no silver bullet and offer you a number of models to choose from.

  • Immutable
  • Freezable
  • Reader/Writer Synchronized
  • Synchronized
  • Actor
  • Thread Affine
  • Thread Safe

Leverage your investment – PostSharp works with any C#/VB codebase. There’s no need to move to a different language to achieve thread safety.

Adopt incrementally – You can add thread safety one component at a time. There’s no need for a full application rewrite.

Scott Hanselman

PostSharp is a pretty amazing piece of software. Abstractions like PostSharp are the whole point of what the computer is supposed to do for us. So why not hide that?

Scott Hanselman, Principal Program Manager, Microsoft

PostSharp makes .NET languages stronger