Skip to content

OnceDisposable class

Attributes: [DebuggerDisplay("{DebuggerDisplay,nq}")]

Defined in

Namespace: ReactiveUI.Primitives.Disposables Assembly: ReactiveUI.Disposables.dll Full name: ReactiveUI.Primitives.Disposables.OnceDisposable Modifiers: public sealed

Summary

View source

A disposable holder whose inner disposable can be set exactly once. Replaces SingleAssignmentDisposable. Subsequent assignments throw InvalidOperationException; if the holder has been disposed before assignment, the supplied disposable is disposed immediately and no exception is thrown.

Applies to

net10.0, net10.0-browserwasm1.0, net10.0-desktop1.0, net9.0, net9.0-browserwasm1.0, net9.0-desktop1.0, net8.0, net8.0-ios17.5, net8.0-maccatalyst17.5, net8.0-macos14.2, net8.0-macos14.5, net8.0-tvos17.2, netstandard2.1, net462, net481

Class hierarchy
classDiagram
class OnceDisposable
class IsDisposed {
    <>
}
IsDisposed <|.. OnceDisposable
class IDisposable {
    <>
}
IDisposable <|.. OnceDisposable

Implements: IsDisposed, IDisposable

Constructors

NameSummary
.ctor

Properties

NameSummary
IsAssignedGets a value indicating whether a disposable has been assigned.
IsDisposedGets a value indicating whether this instance has been disposed.
DisposableGets or sets the inner disposable. Setting more than once throws.

Methods

NameSummary
Dispose
Inherited members