c# - Autofac heavy Initialize task -
is there way autofac di add initialize method run on different thread registered component?
instead of having this:
public class service { public service() { // heavy init task } } have this:
public class service { public service() { // no logic } // should run on different thread when service created public void init() { // heavy init } }
you can register using lambda expressions, in can add code. can start task calls init-method.
something this:
builder.register(c => { var instance = new service(); new task(() => instance.init()).start(); return instance; }).as<iservice>().singleinstance();
Comments
Post a Comment