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); }
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); }
public void SetTask(DistributedTask task) { notifyCache.Publish(task.DistributedTaskCache, CacheNotifyAction.InsertOrUpdate); }
public void SetTask(DistributedTask task) { cache.HashSet(key, task.Id, task); }
public void SetTask(DistributedTask task) { DistributedTaskCacheNotify.SetTask(task); }