Windsor has its own IStartable
interface. If you want Windsor to register your objects and create/run them immediately after that you'd use Startable Facility for that.
To clarify, there are two concepts here:
IStartable
interface, which provides Start
and Stop
methods. This is a lifecycle interfaces that provide lifecycle callbacks: Start
being called right after a component instance gets created (after the constructor runs)
Startable Facility, which forces your IStartable
components to be instantiated and started immediately after installers have ran.
Here's what the code would look like:
container.AddFacility<StartableFacility>(f => f.DeferredStart());
container.Install(FromAssembly.This());
// by here all startable are started
If you're on Windsor 3.3 or later you can also manually trigger the startables to start (which is useful if you need to do some extra setup for them)
var flag = new StartFlag();
container.AddFacility<StartableFacility>(f => f.DeferredStart(flag));
container.Install(FromAssembly.This());
// do whatever else set up your app needs
// when ready, signal the flag
flag.Signal();
// by here all startable are started