唤醒指定任务马上开始处理任务
大石头 authored at 2017-12-01 13:41:57
891.00 B
X
using System;
using NewLife.Log;

namespace NewLife.Agent
{
    /// <summary>任务接口</summary>
    public interface IJob
    {
        /// <summary>执行一次任务</summary>
        /// <param name="context"></param>
        void Execute(JobContext context);
    }

    /// <summary>工作任务基类</summary>
    public abstract class JobBase : IJob
    {
        /// <param name="context"></param>
        public abstract void Execute(JobContext context);

        #region 日志
        /// <summary>日志</summary>
        public ILog Log { get; set; } = Logger.Null;

        /// <summary>写日志</summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        public void WriteLog(String format, params Object[] args)
        {
            Log?.Info(format, args);
        }
        #endregion
    }
}