Skip to content

)}

Disposable.Create(Action) method

Defined in

Type: Disposable Namespace: System.Reactive.Disposables Assembly: System.Reactive.dll

Applies to

netstandard2.0

Overloads

  • 1. public static IDisposable Create(Action dispose)
  • 2. public static IDisposable Create<TState>(TState state, Action<TState> dispose)

1. Overload

public static IDisposable Create(Action dispose)

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

Parameters

NameTypeDescription
disposeActionAction to run during the first call to Dispose. The action is guaranteed to be run at most once.

Returns: IDisposable -- The disposable object that runs the given action upon disposal.

Exceptions

TypeCondition
System.ArgumentNullExceptiondispose is null.

2. Overload

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

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

Type parameters

NameDescription
TState--

Parameters

NameTypeDescription
stateTStateThe state to be passed to the action.
disposeActionAction to run during the first call to Dispose. The action is guaranteed to be run at most once.

Returns: IDisposable -- The disposable object that runs the given action upon disposal.

Exceptions

TypeCondition
System.ArgumentNullExceptiondispose is null.