Pular para o conteúdo principal
Versão: 10.4.1

ITLab.Template.DevPack.Actions

Provides disposable action wrappers for deterministic cleanup and resource release.

Componentes

TipoNomeResponsabilidade
ClassDisposeActionInvokes a callback delegate when disposed
ClassDisposeAction<T>Generic variant carrying a typed state value alongside the cleanup callback

Como usar

// Register a cleanup action scoped to a using block.
using var cleanup = new DisposeAction(() => cache.Invalidate(key));
await DoWorkAsync();
// Cleanup is called automatically at end of scope.

O que não fazer

  • Do not use DisposeAction to hide side effects that should be explicit method calls.
  • Do not capture heavyweight objects in the callback to avoid unintentional lifetime extension.

Extensão pelo produto

  • Products can compose DisposeAction with async patterns using IAsyncDisposable wrappers.