duheng
2024-05-22 157b56b903b53847c7257ff8548d3a38cec2e92c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
namespace IStation.Server
{
    /// <summary>
    /// 预测任务
    /// </summary>
    [DisallowConcurrentExecution]//此特性标识 必须等待这次任务执行完成后,才能执行下次任务
    public class PredictCronJob : IJob
    {
        /// <summary>
        ///
        /// </summary>
        public Task Execute(IJobExecutionContext context)
        {
            return Task.Run(() =>
            {
                try
                {
                    // Console.WriteLine(DateTime.Now.ToString());
                    LogHelper.Info($"{DateTime.Now}");
                    //代码执行
                }
                catch (Exception ex)
                {
                    LogHelper.Error("预测任务中,出错", ex);
                    var e = new JobExecutionException(ex);
                    throw e;
                }
            });
        }
    }
}