Skip to content

Startup Services

What are they?

Startup services are a great way to hook events IMMEDIATELY after the dependency injection container has been built. They support full dependency injection like other services.

The startup of these services is NOT asynchronous for a reason - the startup of your application is not asynchronous. If you go async, the platform is not waiting for you to finish.


namespace Whatever;

public class MyStartupService : Shiny.IShinyStartupTask
    public void Start()
        // great to hook global events here (ie. Logout, delete local database?)

And registering

using Shiny; // to emerge the extension methods

// wherever you register your services with the service collection
ServiceCollection services;
services.AddShinyService<MyStartupService>(); // registers as a singleton

services.BuildServiceProvider(); // the Start method will basically execute right here