Ejemplo n.º 1
0
        /// <summary>
        /// Executes the module service
        /// </summary>
        /// <param name="stoppingToken">The stopping token</param>
        /// <returns>A task</returns>
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            await Task.Delay(1, stoppingToken);

            if (_deviceProvider == null)
            {
                _logger.LogError("No Device Provider Set, Cannot Initialize!!!");
                return;
            }

            var version = Assembly.GetEntryAssembly().GetName().Version.ToString().Substring(0, 5);

            _logger.LogInformation($"Initializing Chroma Control - {_deviceProvider.Name} v{version}...");
            _logger.LogInformation("Initializing Device Provider...");

            _deviceProvider.Initialize();
            _deviceProvider.RequestControl();

            foreach (var device in _deviceProvider.Devices)
            {
                _logger.LogInformation($"Found Device: {device.Name} - {device.Lights.Count()} Lights");
            }

            _logger.LogInformation("Initializing Razer Chroma Broadcast SDK...");

            RzChromaBroadcastAPI.Init(_deviceProvider.GetGuid());

            RzChromaBroadcastAPI.RegisterEventNotification(OnChromaBroadcastEvent);

            _logger.LogInformation($"Chroma Control - {_deviceProvider.Name} Started Succesfully!");

            while (!stoppingToken.IsCancellationRequested)
            {
                await Task.Delay(1000, stoppingToken);
            }

            RzChromaBroadcastAPI.UnRegisterEventNotification();
            RzChromaBroadcastAPI.UnInit();
        }