![]() |
VOOZH | about |
dotnet add package Nito.Disposables --version 2.5.0
NuGet\Install-Package Nito.Disposables -Version 2.5.0
<PackageReference Include="Nito.Disposables" Version="2.5.0" />
<PackageVersion Include="Nito.Disposables" Version="2.5.0" />Directory.Packages.props
<PackageReference Include="Nito.Disposables" />Project file
paket add Nito.Disposables --version 2.5.0
#r "nuget: Nito.Disposables, 2.5.0"
#:package Nito.Disposables@2.5.0
#addin nuget:?package=Nito.Disposables&version=2.5.0Install as a Cake Addin
#tool nuget:?package=Nito.Disposables&version=2.5.0Install as a Cake Tool
IDisposable helper types.
Disposable/AsyncDisposable - When disposed, invokes an Action/Func<ValueTask>.CollectionDisposable/AsyncCollectionDisposable - When disposed, disposes a collection of other disposables.IReferenceCountedDisposable<T> - Maintains a reference count for a disposable and disposes it when the reference count reaches zero.NoopDisposable - When disposed, does nothing.The Disposable type wraps an Action, and invokes that Action exactly once when it is disposed. The first thread to call Dispose is the one that invokes the Action; all other threads that call Dispose are blocked until the Action is completed. Once the Action is completed, it is never invoked again; future calls to Disposable.Dispose are no-ops.
You can create a Disposable by calling Disposable.Create(Action) or new Disposable(Action).
AsyncDisposable is exactly the same as Disposable except it wraps a Func<ValueTask>.
You can call Abandon to have the Disposable/AsyncDisposable abandon its disposal work and do nothing when it is disposed. Abandon returns the Action (or Func<ValueTask>) that it would have taken on disposal; this can be passed to Create to transfer ownership of the disposal actions.
If the Action (or Func<Task>) throws an exception, only the first caller of Dispose (or DisposeAsync) will observe the exception. All other calls to Dispose / DisposeAsync will wait for the delegate to complete, but they will not observe the exception.
You can append an Action to a Disposable by calling its Add method with the Action to add. When the Disposable is disposed, it will call its actions in reverse order. When Add is called, if the Disposable is already disposed (or is in the process of being disposed by another thread), then the additional Action is invoked immediately by the current thread after the disposal completes, and the other thread is not blocked waiting for the Action to complete.
AsyncDisposable may also have multiple delegates. By default, they are all invoked serially in reverse order, but you can change this to concurrent by creating the instance with the AsyncDisposeFlags.ExecuteConcurrently flag.
CollectionDisposable contains a collection of IDisposable instances, and disposes them all exactly once when it is disposed. The first thread to call Dispose is the one that disposes all instances; all other threads that call Dispose are blocked until all instances have been disposed. Once disposed, future calls to CollectionDisposable.Dispose are no-ops.
You can create a CollectionDisposable by calling CollectionDisposable.Create(...) or new CollectionDisposable(...), passing the collection of disposables.
You can also append a disposable to the CollectionDisposable by calling its Add method and passing it the disposable. If the CollectionDisposable is already disposed (or is in the process of being disposed by another thread), then the additional disposable is disposed immediately by the current thread after the disposal completes, and the other thread is not blocked waiting for the additional disposable to dispose.
AsyncCollectionDisposable is exactly the same as CollectionDisposable except it is a collection of IAsyncDisposable instances. You can also create a mixed collection (containing both IDisposable and IAsyncDisposable instances) by calling ToAsyncDisposable on your IDisposable instances.
You can call Abandon to have the CollectionDisposable/AsyncCollectionDisposable abandon its disposal work and do nothing when it is disposed. Abandon returns the IEnumerable<IDisposable> (or IEnumerable<IAsyncDisposable>) that it would have disposed; this can be passed to Create to transfer ownership of the disposal actions.
By default, all IAsyncDisposable instances are disposed serially in reverse order, but you can change this to concurrent by creating the AsyncCollectionDisposable instance with the AsyncDisposeFlags.ExecuteConcurrently flag.
CollectionDisposable can be used as a wrapper to enforce only-dispose-once semantics on another disposable. If a type IncorrectDisposable has a Dispose method that breaks if it is called more than once, then CollectionDisposable.Create(incorrectDisposable) returns an IDisposable that will only invoke IncorrectDisposable.Dispose a single time, regardless of how many times you call CollectionDisposable.Dispose.
You can create a reference-counted disposable wrapping a target disposable by passing the target disposable to ReferenceCountedDisposable.Create. The reference-counted disposable represents an increment of the reference count, and decrements that reference count when disposed. When the reference count reaches zero, the target disposable is disposed.
You can increment the reference count by calling IReferenceCountedDisposable<T>.AddReference, which returns an independent reference-counted disposable representing its own increment of the reference count.
A reference-counted disposable can access its underlying target disposable via IReferenceCountedDisposable<T>.Target.
You can create a weak-reference-counted disposable by calling IReferenceCountedDisposable<T>.AddWeakReference. Weak-reference-counted disposables weakly reference the target disposable and the reference count. They do not represent an increment of the reference count.
You can attempt to increment the reference count for a weak-reference-counted disposable by calling IWeakReferenceCountedDisposable<T>.TryAddReference. If successful, this method returns a (strong) reference-counted disposable.
You can also attempt to access the underlying target disposable via IWeakReferenceCountedDisposable<T>.TryGetTarget.
Reference-counted disposables by default use an ephemeron for the reference count, so calling ReferenceCountedDisposable.Create multiple times on the same target disposable instance will share the underlying reference count. If the reference count is already be zero, this method will throw ObjectDisposedException; to avoid this exception, you can call ReferenceCountedDisposable.TryCreate.
If you want to use a new reference count and not use the ephemeron, you can call ReferenceCountedDisposable.CreateWithNewReferenceCounter. This usage avoids ephemerons, which put pressure on the garbage collector.
A type implementing both IDisposable and IAsyncDisposable that does nothing when disposed.
You can retrieve the singleton instance via NoopDisposable.Instance.
The SingleDisposable<T> type is a base type for disposables that desire exactly-once semantics, blocking other threads calling Dispose until the initial Dispose is complete. Both Disposable and CollectionDisposable inherit from this type.
The type T is an immutable type that represents the contextual state of the instance. It is initialized in the constructor, optionally updated by calling TryUpdateContext, and finally retrieved and passed to Dispose(T) exactly once when Dispose() is called.
When the base type invokes Dispose(T), your derived type should perform whatever disposing logic it needs to.
AsyncSingleDisposable<T> is exactly the same as SingleDisposable<T> except that it implements IAsyncDisposable instead of IDisposable.
If Dispose(T) (or DisposeAsync(T)) throws an exception, only the first caller of Dispose (or DisposeAsync) will observe the exception. All other calls to Dispose / DisposeAsync will wait for the delegate to complete, but they will not observe the exception.
The SingleNonblockingDisposable<T> type is a base type for disposables that desire exactly-once semantics without blocking other threads calling Dispose. It works exactly like SingleDisposable<T>, except that once disposal has started, other threads calling Dispose will return immediately, treating the additional Dispose calls as a no-op.
AsyncSingleNonblockingDisposable<T> is exactly the same as SingleNonblockingDisposable<T> except that it implements IAsyncDisposable instead of IDisposable.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp1.0 netcoreapp1.0 was computed. netcoreapp1.1 netcoreapp1.1 was computed. netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard1.0 netstandard1.0 is compatible. netstandard1.1 netstandard1.1 was computed. netstandard1.2 netstandard1.2 was computed. netstandard1.3 netstandard1.3 was computed. netstandard1.4 netstandard1.4 was computed. netstandard1.5 netstandard1.5 was computed. netstandard1.6 netstandard1.6 was computed. netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net45 net45 was computed. net451 net451 was computed. net452 net452 was computed. net46 net46 was computed. net461 net461 is compatible. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen30 tizen30 was computed. tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Universal Windows Platform | uap uap was computed. uap10.0 uap10.0 was computed. |
| Windows Phone | wp8 wp8 was computed. wp81 wp81 was computed. wpa81 wpa81 was computed. |
| Windows Store | netcore netcore was computed. netcore45 netcore45 was computed. netcore451 netcore451 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Nito.Disposables:
| Package | Downloads |
|---|---|
|
Nito.AsyncEx.Tasks
Common helper methods for tasks as used in asynchronous programming. |
|
|
Nito.Cancellation
Helper types for working with cancellation tokens and sources. |
|
|
Nito.Mvvm.Core
Basic helper types for MVVM applications. |
|
|
Nito.Mvvm.Async
Asynchronous helper types for MVVM applications. |
|
|
DotCommon
Common Utility Library |
Showing the top 19 popular GitHub repositories that depend on Nito.Disposables:
| Repository | Stars |
|---|---|
|
StephenCleary/AsyncEx
A helper library for async/await.
|
|
|
microsoft/GraphEngine
Microsoft Graph Engine
|
|
|
laochiangx/ABP-ASP.NET-Boilerplate-Project-CMS
ABP module-zero +AdminLTE+Bootstrap Table+jQuery+Redis + sql server+quartz+hangfire权限管理系统
|
|
|
Kyrodan/KeeAnywhere
A cloud storage provider plugin for KeePass Password Safe
|
|
|
xamarin/Xamarin.Auth
Xamarin.Auth
|
|
|
yswenli/SAEA
SAEA.Socket is a high-performance IOCP framework TCP based on dotnet standard 2.0; Src contains its application test scenarios, such as websocket,rpc, redis driver, MVC WebAPI, lightweight message server, ultra large file transmission, etc. SAEA.Socket是一个高性能IOCP框架的 TCP,基于dotnet standard 2.0;Src中含有其应用测试场景,例如websocket、rpc、redis驱动、MVC WebAPI、轻量级消息服务器、超大文件传输等
|
|
|
octgn/OCTGN
Online Card and Tabletop Gaming Network
|
|
|
LingFeng-bbben/MajdataPlay
A Simai Player
|
|
|
roubachof/Xamarin-Forms-Practices
Collection of good practices for Xamarin forms developement
|
|
|
StephenCleary/StructuredConcurrency
Structured concurrency support for C#
|
|
|
coenm/ImageHash
Library containing perceptual hash algorithms using the ImageSharp library
|
|
|
isbeorn/nina
N.I.N.A. (Nighttime Imaging 'N' Astronomy) - Advanced astrophotography sequencing software for Windows, supporting full automation of imaging sessions.
|
|
|
MeltyPlayer/MeltyTool
Multitool for viewing/extracting assets from various N64/GCN/3DS/PC games en-masse.
|
|
|
personball/abplus
Abp Plus, Extension For https://github.com/aspnetboilerplate/aspnetboilerplate
|
|
|
bosima/FireflySoft.RateLimit
It is a rate limiting library based on .Net standard.
|
|
|
StephenCleary/Mvvm
MVVM helpers, including calculated properties and asynchronous notification tasks.
|
|
|
dsa28s/windows-hangul-clock
Hangul Clock for Windows Desktop Widget
|
|
|
real-zony/AliDDNSNet
使用 C# + .NET Core 开发的开源 DDNS 工具,基于阿里云的 DNS API 接口。
|
|
|
mrsalmon1976/Stateless.WorkflowEngine
Basic .NET workflow engine based on the awesome stateless State Machine.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.5.0 | 1,626,353 | 12/8/2023 |
| 2.5.0-alpha.2 | 369 | 12/3/2023 |
| 2.5.0-alpha.1 | 1,343 | 4/2/2023 |
| 2.4.0 | 314,904 | 3/3/2023 |
| 2.3.0 | 649,072 | 12/30/2021 |
| 2.3.0-pre02 | 1,472 | 12/28/2021 |
| 2.3.0-pre01 | 1,680 | 12/11/2021 |
| 2.2.1 | 103,007,799 | 9/25/2021 |
| 2.2.0 | 28,038,964 | 10/3/2020 |
| 2.2.0-pre01 | 4,488 | 6/9/2020 |
| 2.1.0 | 92,153 | 6/8/2020 |
| 2.1.0-pre03 | 1,676 | 6/7/2020 |
| 2.1.0-pre02 | 6,174 | 7/20/2019 |
| 2.1.0-pre01 | 1,982 | 5/29/2019 |
| 2.0.1 | 464,148 | 7/20/2019 |
| 2.0.0 | 35,778,132 | 6/2/2018 |
| 1.2.3 | 14,897,450 | 9/9/2017 |
| 1.2.2 | 1,983,920 | 8/26/2017 |
| 1.2.1 | 17,664 | 8/26/2017 |