Compze.Threading.Interprocess 0.11.1-alpha

Prefix Reserved
This is a prerelease version of Compze.Threading.Interprocess.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Compze.Threading.Interprocess --version 0.11.1-alpha
                    
NuGet\Install-Package Compze.Threading.Interprocess -Version 0.11.1-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Compze.Threading.Interprocess" Version="0.11.1-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Compze.Threading.Interprocess" Version="0.11.1-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Compze.Threading.Interprocess" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Compze.Threading.Interprocess --version 0.11.1-alpha
                    
#r "nuget: Compze.Threading.Interprocess, 0.11.1-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Compze.Threading.Interprocess@0.11.1-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Compze.Threading.Interprocess&version=0.11.1-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Compze.Threading.Interprocess&version=0.11.1-alpha&prerelease
                    
Install as a Cake Tool

Compze.Threading.Interprocess

Cross-process synchronization for Compze.Threading. It brings the same pit-of-success locking model — impossible to forget to lock, automatic deadlock diagnosis with dual stack traces — across process boundaries, backed by the operating system's named mutexes.

Extracted from Compze.Threading 0.7.0-alpha so the cross-process primitives can version independently of the in-process ones. It depends on Compze.Threading for the shared ICriticalSection / IAwaitableCriticalSection abstractions that both the in-process and cross-process implementations satisfy — so an IMutex is an ICriticalSection and an IAwaitableMutex is an IAwaitableCriticalSection, interchangeable with their in-process counterparts wherever the abstraction is what matters.

What it adds

IMutex — a cross-process lock that diagnoses its own deadlocks

A named system Mutex wrapped so it behaves like the rest of Compze.Threading: Global (visible across all login sessions) and Local (one session) variants, cancellation-token support, abandoned-mutex recovery, and the same timeout-and-dual-stack-trace deadlock diagnostics as the in-process IMonitor.

IAwaitableMutex — Monitor.Wait semantics across processes

The full condition-wait model — TakeUpdateLockWhen(condition), TakeReadLockWhen(condition), and the TryTake* variants — working across processes. It releases every nesting level of the lock while waiting and reacquires on signal, mirroring Monitor.Wait exactly. As far as we know, no other .NET library exposes the full Monitor/condition-wait model over a cross-process mutex.

using var mutex = IAwaitableMutex.Global("MyResource", directory);
using(mutex.TakeUpdateLockWhen(() => ResourceIsReady()))
{
    // Exclusive across every process on the machine; the wait released the lock
    // for other processes and reacquired it once the condition held.
}

The async condition waits — TryAwaitAsync, ReadWhenAsync, UpdateWhenAsync, TryUpdateWhenAsync — work across processes too, and hold no thread while they wait: between polls of the signal (see ISignalPollingPolicy below) nothing waits but a timer.

IProcessLock — a lock between processes that any thread can release

A lock on an IMutex can only be released by the thread that took it, so async code can't hold it across an await, nor can an xUnit fixture take it as it is created and release it as it is disposed. An IProcessLock belongs to its holder instead: disposing the IProcessLockHold that taking it returns releases it, from whichever thread. The operating system releases it when the holder's process dies, so a crashed or killed process never leaves it held.

var sandboxTurn = IProcessLock.New("sandbox-turn", directory);
using(await sandboxTurn.TakeAsync("running the sandbox specifications", WaitTimeout.Minutes(20)))
{
    // Every other process taking "sandbox-turn" in this directory waits until the hold is disposed.
}

The wait is a WaitTimeout, not a LockTimeout: a holder may rightly hold it for minutes, so a long wait is no sign of a deadlock. A Take that gives up says what the lock is held for, by which process, and since when; TryTake(purpose, WaitTimeout.Zero) answers at once. The lock is a file in the directory, which its holder keeps open, and a wait tries it every 50 milliseconds: it isn't fair, nor reentrant.

IProcessShared<T> / IAwaitableProcessShared<T>

Pair a shared object with a cross-process mutex to coordinate access to an external resource — a file, a port, a database — across processes. Each process has its own object: for an object the processes really share, see IInterprocessObject<T> below.

IInterprocessObject<T> — an object shared between processes, in a single line of code

An IAwaitableProcessShared<T> whose object every process shares: kept in a memory-mapped file, so a change one process makes is visible to all the others at once, and the object survives the processes and reboots.

  • Atomic updates: every read and update holds the object's cross-process mutex, so a read-modify-write is safe.
  • Waits for conditions: the same condition waits as IAwaitableMutex, with the object loaded for each evaluation of the condition and saved after an update.
  • Recovery from corruption: CorruptionAction says whether an object that can't be read is replaced with its default or left as it is for you to look at. Either way the access that found it throws, saying what happened.
  • Pluggable serialization: JSON with IInterprocessObjectSerializer.Json<T>(), MemoryPack with the Compze.Threading.Interprocess.MemoryPack plugin, or a serializer of your own.
using var visits = IInterprocessObject.NewGlobal("visits", IInterprocessObjectSerializer.Json<Visits>(), () => new Visits(),
                                                 CorruptionAction.ReplaceContentWithDefaultAndThrow, maxBytes: 4 * 1024, directory);
visits.Update(it => it.Count++);

It came here from Compze.InterprocessObject, which is retired: its types are in the namespace Compze.Threading.Interprocess.ResourceAccess now.

ISignalPollingPolicy — the latency-versus-power knob

Awaiting a cross-process condition polls a memory-mapped change counter, because .NET has no portable cross-process kernel signal. Each poll wakes the CPU, and frequent wakeups keep it out of its deep low-power idle states — a real battery cost on laptops. ISignalPollingPolicy decides the poll cadence; the default backs off adaptively (eager at first, then stretching toward a 50 ms cap), and you can supply your own.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (6)

Showing the top 5 NuGet packages that depend on Compze.Threading.Interprocess:

Package Downloads
Compze.Tessaging

Messaging infrastructure for the Compze framework including command, query, and event handling.

Compze.Sql.Sqlite

Discontinued: this is its last version. Compze no longer supports SQLite: it runs one writer at a time, so it could never be a fully supported persistence layer. Use Compze.Sql.MicrosoftSql for SQL Server, Compze.Sql.PostgreSql for PostgreSQL or Compze.Sql.MySql for MySQL. SQLite support for the Compze framework: declares the SQLite domain database that Compze endpoints join. Also carries the SQLite plumbing the Compze.*.Sqlite feature backends share.

Compze.Hosting

Endpoint hosting for the Compze framework — endpoints, endpoint hosts, and the builder that capabilities such as the Tessaging and Typermedia pipelines plug into.

Compze.DbPool

Empty databases on demand for integration testing etc. Supports SQL Server, MySql, PostgreSQL and SQLite

Compze.Teventive.MemoryImageStateStore

A memory image of taggregates: every taggregate held in memory for the container's life, rebuilt at its start from a snapshot of each, which JSON files, or a database's tables, keep. A taggregate store that keeps taggregates as their state, not their history.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.20.0-alpha 0 12/5/2026
0.19.0-alpha 0 12/5/2026
0.18.0-alpha 0 12/5/2026
0.17.1-alpha 0 12/5/2026
0.17.0-alpha 7 12/5/2026
0.16.4-alpha 76 12/5/2026
0.16.3-alpha 203 12/5/2026
0.16.2-alpha 184 12/4/2026
0.16.1-alpha 78 12/4/2026
0.16.0-alpha 314 12/3/2026
0.15.0-alpha 90 12/3/2026
0.14.0-alpha 89 12/2/2026
0.13.0-alpha 277 12/2/2026
0.12.0-alpha 383 11/29/2026
0.11.3-alpha 153 11/28/2026
0.11.2-alpha 143 11/28/2026
0.11.1-alpha 243 11/28/2026
0.11.0-alpha 122 11/27/2026
0.10.0-alpha 107 11/26/2026
0.9.0-alpha 131 11/26/2026
Loading failed

- **Requires newer minor versions of other Compze packages:** Compze.Internals.SystemCE 0.14.0-internal (was 0.12.1-internal). Upgrading to this version upgrades each package listed here too, so their changelogs apply to this upgrade as well.
- **Requires exact versions of the Compze packages whose internals it uses:** Compze.Threading 0.14.1-alpha (was 0.14.0-alpha or newer). Upgrading to this version upgrades each package listed here to exactly that version, so their changelogs apply to this upgrade as well.