v7.3.2018.0614   重构高性能资源池,减少GC压力,增加线程池,让异步任务得到平等竞争CPU的机会
大石头 authored at 2018-06-14 17:56:44
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
    }
}