コード例 #1
0
 public BackgroundTaskScheduler(string tenant, string name, DateTime referenceTime)
 {
     Name          = name;
     Tenant        = tenant;
     ReferenceTime = referenceTime;
     Settings      = new BackgroundTaskSettings()
     {
         Name = name
     };
     State = new BackgroundTaskState()
     {
         Name = name
     };
 }
コード例 #2
0
 public BackgroundTaskScheduler(string tenant, string name, DateTime referenceTime)
 {
     base();
     this.u003cNameu003ek__BackingField   = name;
     this.u003cTenantu003ek__BackingField = tenant;
     this.set_ReferenceTime(referenceTime);
     stackVariable8 = new BackgroundTaskSettings();
     stackVariable8.set_Name(name);
     this.set_Settings(stackVariable8);
     stackVariable11 = new BackgroundTaskState();
     stackVariable11.set_Name(name);
     this.set_State(stackVariable11);
     return;
 }
コード例 #3
0
        /// <summary>
        /// Tries to acquire a lock on the background task if it is atomic and if the lock service is not a local lock, otherwise returns true with a null locker.
        /// </summary>
        public static Task <(ILocker locker, bool locked)> TryAcquireBackgroundTaskLockAsync(this IDistributedLock distributedLock, BackgroundTaskSettings settings)
        {
            if (distributedLock is ILocalLock || !settings.IsAtomic)
            {
                return(Task.FromResult <(ILocker, bool)>((null, true)));
            }

            return(distributedLock.TryAcquireLockAsync(
                       settings.Name + "_LOCK",
                       TimeSpan.FromMilliseconds(settings.LockTimeout),
                       TimeSpan.FromMilliseconds(settings.LockExpiration)));
        }