Ejemplo n.º 1
0
        protected async Task CommandAsync(CancellationToken cancellationToken)
        {
            using (ServiceProvider provider = new ServiceCollection().AddTwitchServices(cancellationToken).BuildServiceProvider(new ServiceProviderOptions {
                ValidateScopes = true, ValidateOnBuild = true
            }))
            {
                using (IServiceScope scope = provider.CreateScope())
                {
                    using (var waiter = new ManualResetEventSlim())
                    {
                        // Initialize data
                        var gameData = scope.ServiceProvider.GetRequiredService <IGameData>();
                        await gameData.LoadDataAsync();

                        ITwitchBot twitchBot = scope.ServiceProvider.GetRequiredService <ITwitchBot>();
                        await twitchBot.InitializeAsync();

                        waiter.Wait(cancellationToken);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 private async Task TwitchBotAsync()
 {
     await twitchBot.InitializeAsync();
 }