Method Finally
View SourceFinally<TSource>(IAsyncEnumerable<TSource>, Action)
Creates a sequence whose termination or disposal of an enumerator causes a finally action to be executed.
Declaration
public static IAsyncEnumerable<TSource> Finally<TSource>(this IAsyncEnumerable<TSource> source, Action finallyAction)
Parameters
Type | Name | Description |
---|---|---|
IAsyncEnumerable<TSource> | source | Source sequence. |
Action | finallyAction | Action to run upon termination of the sequence, or when an enumerator is disposed. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<TSource> | Source sequence with guarantees on the invocation of the finally action. |
Type Parameters
Name | Description |
---|---|
TSource | Source sequence element type. |
Remarks
This method uses deferred execution and streams its results.
Exceptions
Type | Condition |
---|---|
ArgumentNullException |
|