Soenneker.Atomics.Bools
11.0.84
Prefix Reserved
dotnet add package Soenneker.Atomics.Bools --version 11.0.84
NuGet\Install-Package Soenneker.Atomics.Bools -Version 11.0.84
<PackageReference Include="Soenneker.Atomics.Bools" Version="11.0.84" />
<PackageVersion Include="Soenneker.Atomics.Bools" Version="11.0.84" />
<PackageReference Include="Soenneker.Atomics.Bools" />
paket add Soenneker.Atomics.Bools --version 11.0.84
#r "nuget: Soenneker.Atomics.Bools, 11.0.84"
#:package Soenneker.Atomics.Bools@11.0.84
#addin nuget:?package=Soenneker.Atomics.Bools&version=11.0.84
#tool nuget:?package=Soenneker.Atomics.Bools&version=11.0.84
Soenneker.Atomics.Bools
A lightweight atomic boolean wrapper implemented on top of ValueAtomicBool. This is a reference type so it can be safely shared without accidental struct copying.
Install
dotnet add package Soenneker.Atomics.Bools
Usage
Use TrySetTrue when exactly one concurrent caller should win a transition:
using Soenneker.Atomics.Bools;
private readonly AtomicBool _started = new();
public void Start()
{
if (!_started.TrySetTrue())
return;
// Only the false-to-true winner reaches this point.
StartCore();
}
Exchange is useful when the previous state determines the action:
bool wasEnabled = featureEnabled.Exchange(false);
AtomicBool is a reference type, so every holder of the same instance observes the same atomic state. Its individual operations are atomic; a sequence such as if (!Value) Value = true is not. Use TrySetTrue, TrySetFalse, or CompareAndSet for conditional transitions.
What you get
AtomicBool— A lightweight atomic boolean wrapper implemented on top ofValueAtomicBool. This is a reference type so it can be safely shared without accidental struct copying.
API at a glance
| API | What it does | Result / important behavior |
|---|---|---|
AtomicBool.Read() |
Reads the current value of the atomic boolean. | true if reads the current value of the atomic boolean; otherwise, false. |
AtomicBool.Write(value) |
Writes a new value to the atomic boolean. | Returns no value; the requested change is complete when the method returns. |
AtomicBool.Exchange(value) |
Atomically replaces the current value with value and returns the previous value. |
true if atomically replaces the current value with and returns the previous value; otherwise, false. |
AtomicBool.CompareAndSet(expected, newValue) |
Atomically sets the value to newValue if the current value equals expected. |
true if atomically sets the value to if the current value equals; otherwise, false. |
AtomicBool.Value |
Gets or sets the current value of the atomic boolean. | Gets or sets the current value of the atomic boolean. |
AtomicBool.TrySetTrue() |
Attempts to atomically transition the value from false to true. | true if the requested update was applied; otherwise, false. |
AtomicBool.TrySetFalse() |
Attempts to atomically transition the value from true to false. | true if the requested update was applied; otherwise, false. |
AtomicBool.ToString() |
Returns a string representation of the current instance. | The result of the operation. |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Atomics.ValueBools (>= 11.0.57)
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 |
|---|---|---|
| 11.0.84 | 74 | 11/18/2026 |
| 11.0.82 | 93 | 11/11/2026 |
| 11.0.81 | 90 | 11/11/2026 |
| 11.0.80 | 143 | 10/27/2026 |
| 11.0.78 | 102 | 10/26/2026 |
| 11.0.77 | 100 | 10/26/2026 |
| 4.0.76 | 112 | 10/15/2026 |
| 4.0.75 | 111 | 10/14/2026 |
| 4.0.74 | 104 | 10/14/2026 |
| 4.0.73 | 103 | 10/14/2026 |
| 4.0.72 | 108 | 10/14/2026 |
| 4.0.66 | 100 | 10/12/2026 |
| 4.0.64 | 99 | 10/12/2026 |
| 4.0.63 | 100 | 10/11/2026 |
| 4.0.62 | 106 | 10/11/2026 |
| 4.0.61 | 165 | 9/24/2026 |
| 4.0.60 | 114 | 9/24/2026 |
| 4.0.59 | 120 | 9/16/2026 |
| 4.0.58 | 118 | 9/15/2026 |
| 4.0.57 | 110 | 9/15/2026 |
Updated Soenneker.Atomics.ValueBools to 11.0.57