<PackageReference Include="System.Reactive" Version="4.1.4" />

Disposable

public static class Disposable
Provides a set of static methods for creating IDisposable objects.
public static IDisposable Empty { get; }

Gets the disposable that does nothing when disposed.

public static IDisposable Create(Action dispose)

Creates a disposable object that invokes the specified action when disposed.

public static IDisposable Create<TState>(TState state, Action<TState> dispose)

Creates a disposable object that invokes the specified action when disposed.