StackOfDisposables class StackOfDisposables : IDisposable This class will dispose pushed IDisposable objects in LIFO manner. Documentation public StackOfDisposables() public void Dispose() Dispose all objects in the stack. public void Push(IDisposable disposable) push the item at the stack.