예제 #1
0
        public static IApplicationBuilder UseTwitch(this IApplicationBuilder app)
        {
            // get application to dispose and close connections on shutdown
            IApplicationLifetime life = app.ApplicationServices.GetService <IApplicationLifetime>();

            ITwitchChannelLinkProvider twitchChannelLinkProvider = app.ApplicationServices.GetRequiredService <ITwitchChannelLinkProvider>();

            // handle life time jobs
            life.ApplicationStarted.Register(async() => await twitchChannelLinkProvider.StartAsync().ConfigureAwait(false));
            life.ApplicationStopping.Register(async() => await twitchChannelLinkProvider.StopAsync().ConfigureAwait(false));

            return(app);
        }
 public async Task StopAsync(CancellationToken cancellationToken)
 {
     await _twitchChannelLinkProvider.StopAsync().ConfigureAwait(false);
 }