当前位置: 首页 > news >正文

wordpress 中毒seo优化多少钱

wordpress 中毒,seo优化多少钱,赤峰北京网站建设,网站建设技术员目录 创建简易控制台定时任务步骤完整程序 创建简易控制台定时任务 创建winform的可以看:https://blog.csdn.net/wayhb/article/details/134279205 步骤 创建控制台程序 使用vs2019新建项目,控制台程序,使用.net4.7.2项目右键&#xff08…

目录

  • 创建简易控制台定时任务
    • 步骤
    • 完整程序

创建简易控制台定时任务

  • 创建winform的可以看:https://blog.csdn.net/wayhb/article/details/134279205

步骤

  1. 创建控制台程序
  • 使用vs2019
  • 新建项目,控制台程序,使用.net4.7.2
  • 项目右键(管理NuGet程序包),搜索Quartz,安装
    在这里插入图片描述
  1. 使用Quartz.Net官网示例运行程序
  • 打开官网https://www.quartz-scheduler.net/documentation/quartz-3.x/quick-start.html#trying-out-the-application,在程序入库Program.cs粘贴官网示例
//出现错误右键修复,自动添加包
using Quartz;
using Quartz.Impl;
using Quartz.Logging;
using System;
using System.Threading.Tasks;namespace ConsoleSkWork
{class Program{private static async Task Main(string[] args){LogProvider.SetCurrentLogProvider(new ConsoleLogProvider());// Grab the Scheduler instance from the FactoryStdSchedulerFactory factory = new StdSchedulerFactory();IScheduler scheduler = await factory.GetScheduler();// and start it offawait scheduler.Start();// define the job and tie it to our HelloJob classIJobDetail job = JobBuilder.Create<HelloJob>().WithIdentity("job1", "group1").Build();// Trigger the job to run now, and then repeat every 10 secondsITrigger trigger = TriggerBuilder.Create().WithIdentity("trigger1", "group1").StartNow().WithSimpleSchedule(x => x.WithIntervalInSeconds(10).RepeatForever()).Build();// Tell Quartz to schedule the job using our triggerawait scheduler.ScheduleJob(job, trigger);// some sleep to show what's happeningawait Task.Delay(TimeSpan.FromSeconds(60));// and last shut down the scheduler when you are ready to close your programawait scheduler.Shutdown();Console.WriteLine("Press any key to close the application");Console.ReadKey();}// simple log provider to get something to the console//https://www.quartz-scheduler.net/documentation/quartz-3.x/quick-start.html#trying-out-the-applicationprivate class ConsoleLogProvider : ILogProvider{public Logger GetLogger(string name){return (level, func, exception, parameters) =>{if (level >= LogLevel.Info && func != null){Console.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] [" + level + "] " + func(), parameters);}return true;};}public IDisposable OpenNestedContext(string message){throw new NotImplementedException();}public IDisposable OpenMappedContext(string key, object value, bool destructure = false){throw new NotImplementedException();}}}public class HelloJob : IJob{public async Task Execute(IJobExecutionContext context){await Console.Out.WriteLineAsync("Greetings from HelloJob!");}}
}
  • 运行控制台程序
    在这里插入图片描述
    说明:
    info是日志插件输出的
    hellojob就是任务触发的
  1. 添加触发监听器
  • 触发监听器是用于监听触发器的
  • 添加触发监听器可以在任务执行前后执行其他动作,例如输出下一次该任务执行时间
  • 触发监听器官网解释:https://www.quartz-scheduler.net/documentation/quartz-3.x/tutorial/trigger-and-job-listeners.html
  • 继承触发监听器接口有4个方法需要实现
//触发器执行前
public async Task TriggerFired(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)
{}
// 判断作业是否继续(true继续,false本次不触发)
public async Task<bool> VetoJobExecution(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default)
{}
//  触发完成
public async Task TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode, CancellationToken cancellationToken = default)
{}
// 触发失败
public async Task TriggerMisfired(ITrigger trigger, CancellationToken cancellationToken = default)
{}
  • 主程序中添加触发监听器
           // 将trigger监听器注册到调度器scheduler.ListenerManager.AddTriggerListener(new CustomTriggerListener());

完整程序

  • Program.cs
using System;
using System.Threading.Tasks;using Quartz;
using Quartz.Impl;
using Quartz.Logging;namespace ConsoleApp1
{public class Program{private static async Task Main(string[] args){LogProvider.SetCurrentLogProvider(new ConsoleLogProvider());// Grab the Scheduler instance from the FactoryStdSchedulerFactory factory = new StdSchedulerFactory();IScheduler scheduler = await factory.GetScheduler();// and start it offawait scheduler.Start();// define the job and tie it to our HelloJob classIJobDetail job = JobBuilder.Create<HelloJob>().WithIdentity("job1", "group1").Build();// Trigger the job to run now, and then repeat every 10 secondsITrigger trigger = TriggerBuilder.Create().WithIdentity("trigger1", "group1").StartNow().WithSimpleSchedule(x => x.WithIntervalInSeconds(10).RepeatForever()).Build();// 将trigger监听器注册到调度器scheduler.ListenerManager.AddTriggerListener(new CustomTriggerListener());// Tell Quartz to schedule the job using our triggerawait scheduler.ScheduleJob(job, trigger);// some sleep to show what's happeningawait Task.Delay(TimeSpan.FromSeconds(60));// and last shut down the scheduler when you are ready to close your programawait scheduler.Shutdown();Console.WriteLine("Press any key to close the application");Console.ReadKey();}// simple log provider to get something to the consoleprivate class ConsoleLogProvider : ILogProvider{public Logger GetLogger(string name){return (level, func, exception, parameters) =>{if (level >= LogLevel.Info && func != null){Console.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] [" + level + "] " + func(), parameters);}return true;};}public IDisposable OpenNestedContext(string message){throw new NotImplementedException();}public IDisposable OpenMappedContext(string key, object value, bool destructure = false){throw new NotImplementedException();}}}public class HelloJob : IJob{public async Task Execute(IJobExecutionContext context){//获取当前时间DateTime currentDateTime = DateTime.UtcNow;await Console.Out.WriteLineAsync("当前日期和时间:" + currentDateTime.AddHours(8));}}
}
  • CustomTriggerListener.cs
using Quartz;
using System;
using System.Threading;
using System.Threading.Tasks;namespace ConsoleApp1
{//继承监听器接口public class CustomTriggerListener : ITriggerListener{public string Name => "CustomTriggerListener";//触发器执行前public async Task TriggerFired(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default){Console.WriteLine("【*********************************************】");Console.WriteLine($"【{Name}】---【TriggerFired】-【触发】");await Task.CompletedTask;}// 判断作业是否继续(true继续,false本次不触发)public async Task<bool> VetoJobExecution(ITrigger trigger, IJobExecutionContext context, CancellationToken cancellationToken = default){Console.WriteLine($"【{Name}】---【VetoJobExecution】-【判断作业是否继续】-{true}");return await Task.FromResult(cancellationToken.IsCancellationRequested);}//  触发完成public async Task TriggerComplete(ITrigger trigger, IJobExecutionContext context, SchedulerInstruction triggerInstructionCode, CancellationToken cancellationToken = default){Console.WriteLine($"【{Name}】---【TriggerComplete】-【触发完成】");//获取下次执行日期时间UTC,将UTC时间转换成北京时间DateTimeOffset dd = (DateTimeOffset)trigger.GetNextFireTimeUtc();Console.WriteLine("【下次执行时间:】"+dd.DateTime.AddHours(8));await Task.CompletedTask;}// 触发失败public async Task TriggerMisfired(ITrigger trigger, CancellationToken cancellationToken = default){Console.WriteLine($"【{Name}】---【TriggerMisfired】【触发作业】");await Task.CompletedTask;}}}
http://www.yidumall.com/news/8199.html

相关文章:

  • 建设部网站施工合同范本去哪找南宁百度关键词推广
  • 网站后台源代码更改常见的网站推广方法有哪些
  • 一站式做网站费用东莞百度seo排名
  • 一个旅游网站建设推销产品怎么推广
  • 重庆做网站公司有哪些长春网络推广优化
  • 上海市做网站广东整治互联网霸王条款
  • 网站建设视频教程下载全球搜官网
  • 长春做网站 长春万网优秀营销软文范例300字
  • 做网站如何做视频推广普通话手抄报简单漂亮
  • 中小网站建设五个常用的搜索引擎
  • 做电影网站放抢先版广点通推广登录入口
  • 安徽网新网站建设seo实战密码第四版pdf
  • 汉中建设工程招标投标信息网上海短视频seo优化网站
  • 网站建设 环保素材怎么上百度搜索
  • asp.net怎么做网站济南seo优化外包服务
  • 网站开发都用什么数据库360搜索引擎
  • 保健品网站设计百度推广登录入口
  • 网站建设 深圳深圳推广公司推荐
  • 做影视网站须要注意什么seo推广教程
  • 一般公司网站是什么设计师做seo关键词推广
  • 好多公司为啥只做网站 不考虑推广app开发者需要更新此app
  • 成都哪家做网站最好怎么在百度免费推广
  • 建个网站需要多少钱费用百度广告投放电话
  • 哪个网站上可以做代打2023必考十大时政热点
  • 如何利用织梦cms做企业网站百度贴吧热线客服24小时
  • 网站开发设计流程图网络推广外包搜索手机蛙软件
  • 石岩做网站公司seo软件开发
  • 类似一起做网站的网站网络营销和电子商务的区别
  • 自己做网站 做什么好郑州今日重大新闻
  • 外贸网站建设介绍网站首页推广