mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
add proper async try/catch to Agent
This commit is contained in:
parent
337d4d9692
commit
689e187ea9
2 changed files with 23 additions and 3 deletions
|
|
@ -26,5 +26,11 @@ public void Log(string message)
|
|||
Console.WriteLine(message);
|
||||
telemetryClient.TrackTrace(message);
|
||||
}
|
||||
|
||||
public void Log(Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
telemetryClient.TrackException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using FilterLists.Services.DependencyInjection.Extensions;
|
||||
using FilterLists.Services.Snapshot;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
@ -41,10 +43,22 @@ private static void BuildServiceProvider()
|
|||
|
||||
private static void CaptureSnapshots(int batchSize)
|
||||
{
|
||||
var snapshotService = serviceProvider.GetService<SnapshotService>();
|
||||
logger.Log("Capturing FilterList snapshots...");
|
||||
snapshotService.CaptureAsync(batchSize).Wait();
|
||||
TryCaptureAsync(batchSize).Wait();
|
||||
logger.Log("Snapshots captured.");
|
||||
}
|
||||
|
||||
private static async Task TryCaptureAsync(int batchSize)
|
||||
{
|
||||
var snapshotService = serviceProvider.GetService<SnapshotService>();
|
||||
try
|
||||
{
|
||||
await snapshotService.CaptureAsync(batchSize);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.Log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue