<PackageReference Include="System.Reactive" Version="4.2.0-preview.566" />

SingleAssignmentDisposable

Represents a disposable resource which only allows a single assignment of its underlying disposable resource. If an underlying disposable resource has already been set, future attempts to set the underlying disposable resource will throw an InvalidOperationException.
public IDisposable Disposable { get; set; }

Gets or sets the underlying disposable. After disposal, the result of getting this property is undefined.

public bool IsDisposed { get; }

Gets a value that indicates whether the object is disposed.

Initializes a new instance of the SingleAssignmentDisposable class.

public void Dispose()

Disposes the underlying disposable.