protected override async Task RunAsync(CancellationToken cancellationToken) { var uptime = Stopwatch.StartNew(); try { ConfigurationSection enumerationPerformanceTestConfiguration = this.Context.CodePackageActivationContext.GetConfigurationSection("EnumerationPerformanceTest"); string connectionString = enumerationPerformanceTestConfiguration.GetStringValue("TargetConnectionString"); connectionString = Helpers.GetServerAddressIfNotProvided(connectionString); ulong timeStreamId = enumerationPerformanceTestConfiguration.GetUInt64Value("TimeStream"); while (!cancellationToken.IsCancellationRequested) { using (var ringMaster = new RetriableRingMasterClient(s => Helpers.CreateRingMasterTimeStreamRequestHandler(s, cancellationToken, timeStreamId), connectionString)) { await Task.Run(() => this.GetChildrenPerformanceTest(ringMaster, enumerationPerformanceTestConfiguration, cancellationToken)); } await Task.Delay(TimeSpan.FromSeconds(30), cancellationToken); } } catch (Exception ex) { EnumerationStressServiceEventSource.Log.RunAsyncFailed(ex.ToString()); throw; } finally { EnumerationStressServiceEventSource.Log.Terminated((long)uptime.Elapsed.TotalSeconds); } }