Ejemplo n.º 1
0
        public static bool QueueForExecution(dynamic job, int?priority = null, DateTime?runAt = null, Func <ScheduledJob, RepeatInfo> repeat = null)
        {
            var scheduledJob = CreateScheduledJob(job, priority ?? DefaultPriority, runAt);
            var repeatInfo   = repeat != null?repeat(scheduledJob) : null;

            if (DelayJobs)
            {
                EnsureBackend();
                Backend.Save(scheduledJob, repeatInfo);
                return(true);
            }
            if (_worker == null)
            {
                CreateAndStartWorker();
            }
            return(_worker != null && _worker.AttemptJob(scheduledJob, persist: false));
        }