Install-Package Cogs.Disposal -Version 1.5.1
dotnet add package Cogs.Disposal --version 1.5.1
<PackageReference Include="Cogs.Disposal" Version="1.5.1" />
paket add Cogs.Disposal --version 1.5.1
#r "nuget: Cogs.Disposal, 1.5.1"
// Install Cogs.Disposal as a Cake Addin #addin nuget:?package=Cogs.Disposal&version=1.5.1 // Install Cogs.Disposal as a Cake Tool #tool nuget:?package=Cogs.Disposal&version=1.5.1
Much like the Components library, this library features base classes that handle things we've written a thousand times over, this time involving disposal.
If you want to go with an implementation of the tried and true
IDisposable, just inherit from
Want a taste of the new
IAsyncDisposable? Then, inherit from
Or, if you want to support both, there's
Additionally, if your object needs to be dynamic, you can use
Each of these features abstract methods to actually do your disposal.
But all of the base classes feature:
- proper implementation of the finalizer and use of
- monitored access to disposal to ensure it can't happen twice
- the ability to override or "cancel" disposal by returning false from the abstract methods (e.g. you're reference counting and only want to dispose when your counter reaches zero)
- a protected
ThrowIfDisposedmethod you can call to before doing anything that requires you haven't been disposed
IsDisposedproperty the value (and change notifications) of which are handled for you
This library provides the
IDisposalStatus interface, which defines the
IsDisposed property and all the base classes implement it.
This library also provides the
INotifyDisposalOverridden interfaces, which add events that notify of these occurrences.
Lastly, this library provides
AsyncDisposableValuesCache, which each represents a cache of key-value pairs which, once disposed by all retrievers, are removed.
|.NET||net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows|
|.NET Core||netcoreapp3.0 netcoreapp3.1|
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Cogs.Disposal:
Cogs for active expressions.
Cogs for active queries.
Cogs for WPF. Includes general-use behaviors, controls, validation rules, and value converters. Also includes ways to leverage Windows features beyond what WPF supports out of the box (such as using enabling blur-behind and binding system commands to controls) and the inclusion of input gestures in styles.
Cogs for Windows. Includes ways to get the Windows theme and create LNK short-cuts.
This package is not used by any popular GitHub repositories.
We fixed a defect in which creating instances of disposable cache values manually caused NRE's when the instances were disposed.