Soenneker.Atomics.NullableBools 4.0.42

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Atomics.NullableBools --version 4.0.42
                    
NuGet\Install-Package Soenneker.Atomics.NullableBools -Version 4.0.42
                    
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="Soenneker.Atomics.NullableBools" Version="4.0.42" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Atomics.NullableBools" Version="4.0.42" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Atomics.NullableBools" />
                    
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 Soenneker.Atomics.NullableBools --version 4.0.42
                    
#r "nuget: Soenneker.Atomics.NullableBools, 4.0.42"
                    
#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 Soenneker.Atomics.NullableBools@4.0.42
                    
#: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=Soenneker.Atomics.NullableBools&version=4.0.42
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Atomics.NullableBools&version=4.0.42
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Atomics.NullableBools

A lightweight atomic tri-state flag implemented on top of an inline ValueAtomicInt. Backing values: -1 = null / unknown 0 = false 1 = true.

Install

dotnet add package Soenneker.Atomics.NullableBools

Usage

The null state is useful for a value that has not been determined yet. TrySet lets one caller publish the first result:

using Soenneker.Atomics.NullableBools;

var availability = new AtomicNullableBool();

if (availability.TrySet(await ProbeAvailability()))
{
    // This caller published the transition from unknown to known.
}

bool? result = availability.Value;
availability.Reset();

GetValueOrFalse and GetValueOrTrue provide explicit fallback policies without changing the stored state.

Prefer the nullable Value, Set, TrySet, and Reset members in application code. Read, Write, and TryCompareExchange expose the raw representation (-1, 0, 1) and do not validate supplied integers; invalid raw values can produce misleading boolean and string results.

What you get

  • AtomicNullableBool — A lightweight atomic tri-state flag implemented on top of an inline ValueAtomicInt. Backing values: -1 = null / unknown 0 = false 1 = true.

API at a glance

API What it does Result / important behavior
AtomicNullableBool.HasValue Gets a value indicating whether the current state is non-null. Gets a value indicating whether the current state is non-null.
AtomicNullableBool.Value Gets or sets the current value as a nullable boolean. Gets or sets the current value as a nullable boolean.
AtomicNullableBool.Read() Reads the raw backing state. -1 (null), 0 (false), or 1 (true).
AtomicNullableBool.GetValueOrFalse() Gets the value, treating null/unknown as false. true if gets the value, treating null/unknown as; otherwise, false.
AtomicNullableBool.GetValueOrTrue() Gets the value, treating null/unknown as true. true if gets the value, treating null/unknown as; otherwise, false.
AtomicNullableBool.Set(value) Sets the state to true or false. Returns no value; the requested change is complete when the method returns.
AtomicNullableBool.TrySet(value) Attempts to set the state to true or false only if the current state is null/unknown. true if the requested update was applied; otherwise, false.
AtomicNullableBool.TryCompareExchange(newState, expected) Attempts to transition the state from expected to newState. true if the requested update was applied; otherwise, false.
AtomicNullableBool.Reset() Resets the state to null/unknown. Returns no value; the requested change is complete when the method returns.
AtomicNullableBool.ToString() Returns a string representation of the current state. Returns string.

Important behavior

  • AtomicNullableBool: Reads establish acquire semantics and writes establish release semantics. This is a mutable reference type. Use as a private field and avoid exposing the instance publicly unless you want shared, aliasable state.
  • AtomicNullableBool.Write(state): Callers must only provide valid values: -1, 0, or 1.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.43 0 8/30/2026
4.0.42 0 8/29/2026
4.0.41 22 8/29/2026
4.0.40 28 8/29/2026
4.0.39 111 7/28/2026
4.0.38 101 7/28/2026
4.0.37 103 7/16/2026
4.0.36 110 7/16/2026
4.0.35 116 6/19/2026
4.0.34 112 6/19/2026
4.0.33 122 6/5/2026
4.0.32 114 6/5/2026
4.0.31 115 6/5/2026
4.0.30 129 4/22/2026
4.0.29 114 4/22/2026
4.0.27 156 3/13/2026
4.0.26 140 3/12/2026
4.0.25 137 3/12/2026
4.0.24 144 3/12/2026
4.0.23 135 3/12/2026
Loading failed

Improve README documentation