Skip to content

Add Container.OnDisposing event for ordered teardown#147

Open
svermeulen wants to merge 1 commit into
gustavopsantos:mainfrom
svermeulen:on-dispose-event
Open

Add Container.OnDisposing event for ordered teardown#147
svermeulen wants to merge 1 commit into
gustavopsantos:mainfrom
svermeulen:on-dispose-event

Conversation

@svermeulen

Copy link
Copy Markdown

Pull Request Template

Description

Adds a public event Action<Container> OnDisposing to Container. It fires at the very top of Container.Dispose() — before children are disposed and before the auto-dispose pass over registered IDisposable instances.

Today, Container.Dispose() runs in a fixed order: child containers in reverse, then resolved/registered IDisposable instances popped in reverse-construction order. There is no extension point for application code to coordinate its own shutdown sequence before this happens.

A single event on Container, fired as the first line of Dispose(). Subscribers can run their own ordered shutdown logic against still-live dependencies, then let the standard teardown proceed.

Also, when combined with #146, allows for complete customization of dispose order

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Ran via Unity Test Runner. All tests passed (though GarbageCollectionTests were skipped since it was run in debug)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings
  • I have checked that Reflex.GettingStarted still runs nicely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant