I have a timerTimer:
private async void QueryReportTimerCallback(object state)
{
if (await semaphoreQueryReportSlim.WaitAsync(10))
{
try
{
if (machineConfigurations != null)
{
await Task.Factory.StartNew(() =>
Parallel.ForEach(machineConfigurations.Where(x => x.QueryReport), async (configuration) =>
{
if (configuration.IsConnectionValid)
{
var queryReport = new QueryReport(configuration, ReportConfigurations, fileContainer, applicationConfiguration, logger);
await QueryAReport(configuration, queryReport);
}
})
);
}
}
catch (Exception e)
{
logger.LogError(e, e.Message);
}
finally
{
semaphoreQueryReportSlim.Release();
}
}
}