Über PostSharp Threading

Schreiben Sie überprüfbaren thread-sicheren Code in .NET.

PostSharp Threading is a pragmatic way to write machine-verified, thread-safe code. Address multithreading at the right level of abstraction with threading models, deadlock detection, and declarative thread dispatching. 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.

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

  • 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 Unsafe
  • 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.

PostSharp Threading Features

  • Framework
    • Method-level aspects
    • Code validation
  • Common
    • Code Contracts
    • Aggregatable (parent/child/visitor)
  • MVVM
    • INotifyPropertyChanged: automatic properties
  • Logging
    • Developer mode (freshly-built apps)
  • Threading
    • Immutable
    • Freezable
    • Synchronized
    • Reader-Writer Synchronized
    • Thread-Affine
    • Actor