|
|
using Admin.Core.Common;
|
|
|
using Aucma.Core.PLc;
|
|
|
using log4net;
|
|
|
using System.Timers;
|
|
|
|
|
|
namespace Aucma.Core.Tasks
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 实时任务列表
|
|
|
/// </summary>
|
|
|
public class AucamTaskService : IAucamTaskService
|
|
|
{
|
|
|
//private static readonly log4net.ILog log = LogManager.GetLogger(typeof(AucamTaskService));
|
|
|
System.Timers.Timer timer1 = new System.Timers.Timer(1000);
|
|
|
System.Timers.Timer timer2 = new System.Timers.Timer(1000);
|
|
|
System.Timers.Timer timer3 = new System.Timers.Timer(1000);
|
|
|
|
|
|
public Task AucamTaskAsync()
|
|
|
{
|
|
|
timer1.Elapsed += new System.Timers.ElapsedEventHandler(Run1); //到达时间的时候执行事件;
|
|
|
timer1.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
|
|
|
timer1.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
|
|
|
timer1.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
|
|
|
|
|
|
timer2.Elapsed += new System.Timers.ElapsedEventHandler(Run2); //到达时间的时候执行事件;
|
|
|
timer2.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
|
|
|
timer2.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
|
|
|
timer2.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
|
|
|
|
|
|
timer3.Elapsed += new System.Timers.ElapsedEventHandler(Run3); //到达时间的时候执行事件;
|
|
|
timer3.AutoReset = true;//设置是执行一次(false)还是一直执行(true);
|
|
|
timer3.Enabled = true;//需要调用 timer.Start()或者timer.Enabled = true来启动它,
|
|
|
timer3.Start();//timer.Start()的内部原理还是设置timer.Enabled = true;
|
|
|
return Task.CompletedTask;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 钣金——前板
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void Run1(object? sender, ElapsedEventArgs e)
|
|
|
{
|
|
|
|
|
|
Console.WriteLine("前板");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 钣金——后板
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void Run2(object? sender, ElapsedEventArgs e)
|
|
|
{
|
|
|
Console.WriteLine("后板");
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 钣金——实时任务列表
|
|
|
/// </summary>
|
|
|
/// <param name="sender"></param>
|
|
|
/// <param name="e"></param>
|
|
|
private void Run3(object? sender, ElapsedEventArgs e)
|
|
|
{
|
|
|
|
|
|
Console.WriteLine("实时任务列表");
|
|
|
}
|
|
|
}
|
|
|
}
|