Пример #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
            }
        }
Пример #2
0
 public override IDisposable AcquireDistributedLock(string resource, TimeSpan timeout)
 {
     return(_postgreSqlConnection.AcquireDistributedLock(resource, timeout));
 }
Пример #3
0
 public override IDisposable AcquireDistributedLock([NotNull] string resource, TimeSpan timeout)
 {
     return(_sqlServerConnection.AcquireDistributedLock(resource, timeout));
 }