We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
public XiaoFeng.Threading.Job emailserver =new XiaoFeng.Threading.Job();
private void emailstart() {
emailserver.Async = true; emailserver.Name = "邮件服务"; emailserver.TimerType = XiaoFeng.Threading.TimerType.Interval; emailserver.Period = 5000; emailserver.StartTime = DateTime.Now; emailserver.SuccessCallBack = job => { /*到时间执行任务*/ MailReceive(); }; emailserver.Start(); }
private void button1_Click(object sender, EventArgs e) {
//timer1.Enabled = Enabled; if (emailserver.Status == XiaoFeng.Threading.JobStatus.NotQueued||emailzt==false) { emailserver.Start();//第二步,执行这里的时候就无法再次运行了 //emailstart() ;使用此方法同样无法在启动了 } else { emailserver.Stop();//第一步,这里执行会正常停止 } }
The text was updated successfully, but these errors were encountered:
作业调度代码如下,实现在启用,停止,再启用
var MyJob = new Job { Name ="我的作业", Period=2000, TimerType= TimerType.Interval, SuccessCallBack = j => { Console.WriteLine($"执行了作业{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fffffff")}"); }, StopCallBack = j => { Console.WriteLine($"停止了作业{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fffffff")}"); } }; Task.Run(() => { var i = 0; while (true) { if (i % 2 == 0) MyJob.Start(); else MyJob.Stop(); Task.Delay(10000).Wait(); i++; } }); Console.ReadLine();
下图为当前代码运行日志
Sorry, something went wrong.
No branches or pull requests
public XiaoFeng.Threading.Job emailserver =new XiaoFeng.Threading.Job();
private void emailstart()
{
private void button1_Click(object sender, EventArgs e)
{
The text was updated successfully, but these errors were encountered: