diff --git a/I18N Commander/Processor/ExportProcessor.cs b/I18N Commander/Processor/ExportProcessor.cs index 371f24c..bffd116 100644 --- a/I18N Commander/Processor/ExportProcessor.cs +++ b/I18N Commander/Processor/ExportProcessor.cs @@ -7,8 +7,8 @@ namespace Processor; public static class ExportProcessor { private static readonly Timer EXPORT_TIMER = new(); - private static readonly object EXPORT_LOCK = new(); - private static readonly SemaphoreSlim EXPORT_SEMAPHORE = new(2); + private static readonly SemaphoreSlim EXPORT_SEMAPHORE_BRICK_WALL = new(2); + private static readonly SemaphoreSlim EXPORT_SEMAPHORE_EXPORTING = new(1); static ExportProcessor() { @@ -19,19 +19,19 @@ public static class ExportProcessor private static async Task ExportToJson() { - if(!await EXPORT_SEMAPHORE.WaitAsync(1)) + if(!await EXPORT_SEMAPHORE_BRICK_WALL.WaitAsync(1)) return; - Monitor.Enter(EXPORT_LOCK); try { + await EXPORT_SEMAPHORE_EXPORTING.WaitAsync(); await using var db = ProcessorMeta.ServiceProvider.GetRequiredService(); await db.ExportAsync(Environment.ExpandEnvironmentVariables(Path.Join(await AppSettings.GetAutoExportDestinationPath(), await AppSettings.GetAutoExportFilename()))); } finally { - Monitor.Exit(EXPORT_LOCK); - EXPORT_SEMAPHORE.Release(); + EXPORT_SEMAPHORE_EXPORTING.Release(); + EXPORT_SEMAPHORE_BRICK_WALL.Release(); } }