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
| Name | Type | Description |
|---|---|---|
dispose | Action | Action 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
| Type | Condition |
|---|---|
| System.ArgumentNullException | dispose 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
| Name | Description |
|---|---|
TState | -- |
Parameters
| Name | Type | Description |
|---|---|---|
state | TState | The state to be passed to the action. |
dispose | Action | Action 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
| Type | Condition |
|---|---|
| System.ArgumentNullException | dispose is null. |