コード例 #1
0
        public void QueueTask(Action <DistributedTask, CancellationToken> action, DistributedTask distributedTask = null)
        {
            if (distributedTask == null)
            {
                distributedTask = new DistributedTask();
            }

            distributedTask.InstanseId = InstanseId;

            var cancelation = new CancellationTokenSource();
            var token       = cancelation.Token;

            cancelations[distributedTask.Id] = cancelation;

            var task = new Task(() => action(distributedTask, token), token, TaskCreationOptions.LongRunning);

            task
            .ConfigureAwait(false)
            .GetAwaiter()
            .OnCompleted(() => OnCompleted(task, distributedTask.Id));

            distributedTask.Status = DistributedTaskStatus.Running;

            if (distributedTask.Publication == null)
            {
                distributedTask.Publication = GetPublication();
            }
            distributedTask.PublishChanges();

            task.Start(scheduler);
        }
コード例 #2
0
        public DistributedTask GetTask(string id)
        {
            var task = new DistributedTask(cache.HashGet <DistributedTaskCache>(key, id));

            if (task != null && task.Publication == null)
            {
                task.Publication = GetPublication();
            }
            return(task);
        }
コード例 #3
0
 public void SetTask(DistributedTask task)
 {
     notifyCache.Publish(task.DistributedTaskCache, CacheNotifyAction.InsertOrUpdate);
 }
コード例 #4
0
 public void SetTask(DistributedTask task)
 {
     cache.HashSet(key, task.Id, task);
 }
コード例 #5
0
 public void SetTask(DistributedTask task)
 {
     DistributedTaskCacheNotify.SetTask(task);
 }