Esempio n. 1
0
        public Worker(Type jobType, JobSetup setup, IContainerFactory containerFactory, ILoggerFactory loggerFactory)
        {
            this.jobType = jobType;
            this.setup = setup;
            this.containerFactory = containerFactory;
            this.thread = new Thread(Run)
            {
                IsBackground = true,
                Name = "Worker: " + jobType.FullName
            };

            this.logger = loggerFactory.GetLogger(jobType, setup.JobId);
        }
Esempio n. 2
0
        public Worker(Type jobType, JobSetup setup, IContainerFactory containerFactory, ILoggerFactory loggerFactory)
        {
            this.jobType          = jobType;
            this.setup            = setup;
            this.containerFactory = containerFactory;
            this.thread           = new Thread(Run)
            {
                IsBackground = true,
                Name         = "Worker: " + jobType.FullName
            };

            this.logger = loggerFactory.GetLogger(jobType, setup.JobId);
        }
Esempio n. 3
0
        public Guid AddJob <TJob>(JobSetup jobSetup)
        {
            if (jobSetup.JobId == Guid.Empty)
            {
                jobSetup.JobId = Guid.NewGuid();
            }

            var state = new Worker(typeof(TJob), jobSetup, this.containerFactory, this.loggerFactory);

            this.jobs[jobSetup.JobId] = state;

            state.Start();

            return(jobSetup.JobId);
        }
Esempio n. 4
0
        public Guid AddJob <TJob>(JobSetup jobSetup)
        {
            if (this._disposed)
            {
                throw new ObjectDisposedException("Scheduler", "Cannot schedule new jobs.");
            }

            if (jobSetup.JobId == Guid.Empty)
            {
                jobSetup.JobId = Guid.NewGuid();
            }

            var state = new Worker(typeof(TJob), jobSetup, this.containerFactory, this.loggerFactory);

            this.jobs[jobSetup.JobId] = state;

            state.Start();

            return(jobSetup.JobId);
        }