private void UpdateTestsModel(object state) { try { using (var statusCakeClient = new StatusCakeClient(_config.UserName, _config.ApiKey)) { _logger.LogInformation("Started to update availabilities"); var watch = new Stopwatch(); watch.Start(); var tests = statusCakeClient.GetTestsAsync().Result; _availabilityModel.Lock(); foreach (var test in tests) { _testsModel.UpdateTest(test); var availabilities = statusCakeClient.GetUptimesAsync(test.TestID).Result; _availabilityModel.UpdateAvailability(test.TestID, availabilities); } _availabilityModel.Unlock(); watch.Stop(); _logger.LogInformation($"Finished to update availabilities. It took {watch.Elapsed.TotalMilliseconds} ms."); } } catch { _logger.LogError("No internet connection?"); } }
static void Main(string[] args) { var client = new StatusCakeClient(); // First, check if the server is already registered var existingTests = client.GetTestsAsync().Result; Console.ReadKey(); }