ITLab.Template.DevPack.Actions
Provides disposable action wrappers for deterministic cleanup and resource release.
Componentes
| Tipo | Nome | Responsabilidade |
|---|---|---|
| Class | DisposeAction | Invokes a callback delegate when disposed |
| Class | DisposeAction<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
DisposeActionto 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
DisposeActionwith async patterns usingIAsyncDisposablewrappers.