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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -