public void Stop([FromServices] IMyApplicationLifetime lifetime) { if (!lifetime.IsStopped && !lifetime.IsStopping) { lifetime.HostApplicationLifetime.StopApplication(); } }
public string Get([FromServices] IMyApplicationLifetime lifetime) { if (lifetime.IsStarted) { return("started"); } if (lifetime.IsStarting) { return("starting"); } if (lifetime.IsStopped) { return("stopped"); } if (lifetime.IsStopping) { return("stopping"); } return(string.Empty); }