Skip to content
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

Async LightInject: adding async CompositionRoots #256

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

moswald
Copy link

@moswald moswald commented Feb 2, 2016

This is going to be the first of a series of Pull Requests to enable asynchronous initialization of the LightInject ServiceContainer.

This first one is a small step, adding an asynchronous version of RegisterFrom, as that touches the least amount of code, causes no breaking changes, and covers what is (if I were to guess) the most common case.

RegisterFromAsync<TAsyncCompositionRoot>() is a counterpart to the current RegisterFrom<TCompositionRoot>(). TAsyncCompositionRoot is a type that must derive from the new IAsyncCompositionRoot.

@seesharper
Copy link
Owner

Looks great. I have just one question though. Given that we are talking about a web application with a startup class or a console application with a main method, how should the RegisterFromAsync method be invoked without doing somthing like

container.RegisterFromAsync<MyAsyncCompositionRoot>().Wait();

Most .Net applications does not support async initialization and that is usually where we put the initialization code for the container.

@moswald
Copy link
Author

moswald commented Feb 5, 2016

Sorry, I've been a bit under the weather and haven't been paying attention to github stuff the past few days.

In my specific case that spawned this PR, I've got a console-like app that spawns an async service in the Main method, and calls myService.RunAsync().Wait() at that point already.

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.

None yet

2 participants