SynchronizedBehavior Class

Definition

Serializes overlapping calls on a stunt with a lock that any thread can release.

public sealed class SynchronizedBehavior : IStuntBehavior, ICloneable

Remarks

Add this behavior first. The pipeline runs the first behavior outermost, so the lock covers every behavior added after it.

The lock is acquired before the rest of the pipeline runs and released when that attempt finishes. A method that returns or keeps the lock until the awaitable settles; the caller resumes after the release.

The thread that acquired the lock throws if it enters again while the lock is held. Any other thread waits. Release runs on the thread that observes completion, which may be a thread-pool thread after the awaitable settles.

Constructor logic and the target must not call back into a member guarded by this behavior. A callback made after the first await of an asynchronous member, from a thread other than the one that entered, waits. When the original call cannot finish without that callback, the wait deadlocks.

The parameterless constructor gives the behavior a private lock, so one behavior locks one stunt. Passing an object shares one lock across every behavior constructed with that instance. The object is an identity key and is never locked.

StuntBuilder clones ICloneable registrations per stunt. A private lock is fresh on each clone. An explicit shared lock stays shared.

Tip: use kind:method, kind:property, kind:ctor. Press Esc to clear.

Constructors (2)

Methods (3)

Explicit Interface Implementation Methods (1)