Exemplo n.º 1
0
 protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 {
     while (!stoppingToken.IsCancellationRequested)
     {
         if (await _userAuthService.IsUserAuthenticated())
         {
             try
             {
                 await GetData();
             }
             catch { }
             await Task.Delay(Convert.ToInt32(Config.LightSettings.PollingInterval * 1000), stoppingToken);
         }
         await Task.Delay(1000, stoppingToken);
     }
 }
Exemplo n.º 2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            if (!Debugger.IsAttached)
            {
                Helpers.OpenBrowser("https://localhost:5001");
            }

            while (!stoppingToken.IsCancellationRequested)
            {
                if (await _userAuthService.IsUserAuthenticated())
                {
                    try
                    {
                        await GetData();
                    }
                    catch { }
                    await Task.Delay(Convert.ToInt32(Config.PollingInterval * 1000), stoppingToken);
                }
                await Task.Delay(1000, stoppingToken);
            }
        }
Exemplo n.º 3
0
 protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 {
     while (!stoppingToken.IsCancellationRequested)
     {
         if (await _userAuthService.IsUserAuthenticated())
         {
             _logger.LogInformation("User is Authenticated, starting worker");
             try
             {
                 await Run();
             }
             catch (Exception e)
             {
                 _logger.LogError(e, "Exception occured restarting worker");
             }
         }
         else
         {
             _logger.LogInformation("User is Not Authenticated, restarting worker");
         }
         await Task.Delay(1000, stoppingToken);
     }
 }