-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add IAsyncComponent
to allow async initialize/terminate
#16536
Conversation
Hi @ronaldbarendse.. Why use components at all? IMO it is a legacy thing, that we should instead obsolete, instead of make more of. I guess you can archive the same with (async) notification handlers of :
|
There are some minor, but very specific things that components allow that can't be (easily) replicated with notifications:
|
Prerequisites
Description
As mentioned in #16430 (comment), it's currently not possible to (correctly) use async methods in components. This adds
IAsyncComponent
and refactors the code to call theInitializeAsync()
/TerminateAsync()
methods instead, which does mean a breaking change in theComponentCollection
(the item type and methods have changed). I did makeIComponent
inherit fromIAsyncComponent
and added default interface methods, so any existing (synchronous) components are still backwards compatible.I've also added 2 base classes to make usage easier:
AsyncComponentBase
- this only initializes/terminates when the application isn't restarting (aka the actual start/stop of the application) and implements a no-opTerminateAsync()
method (as most implementations only require initialization);RuntimeAsyncComponentBase
- inheriting fromAsyncComponentBase
and also takes the runtime level into account, so it only initializes/terminates when the application is running normally.I'll add some example components to help test later...