v9.7.2018.0421   支持运行时修改DAL连接字符串
大石头 authored at 2018-04-21 14:00:47
890.00 B
X
using System;
using System.Collections.Generic;

namespace NewLife.Agent
{
    /// <summary>任务调度器</summary>
    public class JobSchedule
    {
        #region 属性
        /// <summary>任务集合</summary>
        public IJob[] Jobs { get; private set; } = new IJob[0];

        /// <summary>任务个数</summary>
        public Int32 Count => Jobs.Length;
        #endregion

        #region 方法
        /// <summary>向任务调度器添加任务</summary>
        /// <param name="job"></param>
        public void Add(IJob job)
        {
            lock (this)
            {
                var list = new List<IJob>(Jobs);
                if (!list.Contains(job))
                {
                    list.Add(job);

                    Jobs = list.ToArray();
                }
            }
        }
        #endregion
    }
}