mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
Fixed the duplicate notifications
This commit is contained in:
parent
913197ac18
commit
062ba2419b
7 changed files with 49 additions and 51 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue