Beispiel #1
0
        private static void SetTriggerInternal(
            IBackgroundJobClient client,
            JobStorageConnection connection,
            string triggerName)
        {
            var triggerKey = GenerateTriggerKey(triggerName);
            var jobIds     = connection.GetAllItemsFromList(triggerKey);

            try
            {
                using var _ = connection.AcquireDistributedLock(triggerKey, TimeSpan.Zero);

                foreach (var jobId in jobIds)
                {
                    client.ChangeState(jobId, new EnqueuedState());
                }
            }
            catch (DistributedLockTimeoutException)
            {
                // Assume already run
            }
        }
Beispiel #2
0
 public override IDisposable AcquireDistributedLock(string resource, TimeSpan timeout)
 {
     return(_postgreSqlConnection.AcquireDistributedLock(resource, timeout));
 }
Beispiel #3
0
 public override IDisposable AcquireDistributedLock([NotNull] string resource, TimeSpan timeout)
 {
     return(_sqlServerConnection.AcquireDistributedLock(resource, timeout));
 }