Fixed the duplicate notifications

This commit is contained in:
tidusjar 2020-06-22 21:41:58 +01:00
commit 062ba2419b
7 changed files with 49 additions and 51 deletions

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Quartz;
using Quartz.Impl;
@ -15,6 +16,8 @@ namespace Ombi.Helpers
public static IScheduler Scheduler => Instance._scheduler;
private static SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
// Singleton
protected static OmbiQuartz _instance;
@ -84,10 +87,20 @@ namespace Ombi.Helpers
public static async Task TriggerJob(string jobName, string group)
{
if (!(await IsJobRunning(jobName)))
await _semaphore.WaitAsync();
try
{
await Scheduler.TriggerJob(new JobKey(jobName, group));
if (!(await IsJobRunning(jobName)))
{
await Scheduler.TriggerJob(new JobKey(jobName, group));
}
}
finally
{
_semaphore.Release();
}
}