LocalActionDisposable Struct

  • Obsolete: Types with embedded references are not supported in this version of your compiler.

Implements IDisposable by invoking a given Action upon disposal.

This type should be used instead of ActionDisposable when needed in a local scope, as it avoids a heap allocation.

[Obsolete("Types with embedded references are not supported in this version of your compiler.", true)]
public ref struct LocalActionDisposable

Constructors

NameDescription
LocalActionDisposable(Action)Initializes a new instance of the LocalActionDisposable struct.

LocalActionDisposable(Action)

Initializes a new instance of the LocalActionDisposable struct.

public LocalActionDisposable(Action onDispose)

Parameters

onDispose Action
The Action to call upon the first call to LocalActionDisposable.Dispose.

Exceptions

ArgumentNullException
onDispose is null.

See also

Methods

NameDescription
Dispose()When invoked for the first time, invokes the Action passed to the constructor. If / when invoked again, this method does nothing.

Dispose()

When invoked for the first time, invokes the Action passed to the constructor.

If / when invoked again, this method does nothing.

public void Dispose()