Skip to content

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.

2 participants