唤醒指定任务马上开始处理任务
大石头 authored at 2017-12-01 13:41:57
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
    }
}