Core 定时任务之TimeJob
第一:引入NuGet包:
Install-Package Pomelo.AspNetCore.TimedJob -Version 1.1.-rtm-
第二:
在StartUp 中注册Job:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
} public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<AppSettings>(Configuration.GetSection("AppSettings")); services.AddTimedJob();//使用job
} // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
} app.UseTimedJob();/////////////////使用Job
app.UseMvc();
}
}
第三写个类:
public class TimeJob: Job
{
// Begin 起始时间;Interval执行时间间隔,单位是毫秒,建议使用以下格式,此处为3小时;
//SkipWhileExecuting是否等待上一个执行完成,true为等待;
[Invoke(Begin = "2019-8-3 10:30:00", Interval = * , SkipWhileExecuting = true)]
public void Run()
{
//Job要执行的逻辑代码
Console.WriteLine(DateTime.Now);
}
}
//程序只要运行起来,就会自动出发这个TimeJob类,只需要把定时做的业务放在类里就Core 定时任务之TimeJob的更多相关文章
- Asp.Ner Core定时任务
AspNet Core定时任务 纪念人类首张黑洞照片发布 第一种方式BackgroundService 基于后台服务类BackgroundService实现,类所在命名空间Microsoft.Exte ...
- .Net Core 定时任务TimeJob
转载自:https://blog.csdn.net/u013711462/article/details/53449799 定时任务 Pomelo.AspNetCore.TimedJob Pomelo ...
- Core 定时任务之HangFire
ASP.NET Core 使用 Hangfire 很简单,首先,Nuget 安装程序包 > install-package Hangfire -pre 然后ConfigureServices添加 ...
- .net core定时任务
1.HangFire HangFire官网 Hangfire项目实践分享 : 讲解的比较详细 2.Quartz.NET https://www.cnblogs.com/best/p/7658573. ...
- .Net Core2.*学习手册
1.net core 基础知识解析(创建一个.net core网站)(视频录制) 1.1 Startup解析(没写) 1.2 目录结构分析(没写) 1.3 使用静态文件(没写) 1.4 Control ...
- .Net core 使用TimeJob
在我以前的文章中有一个.Net core使用Quartz.Net ,一开始我们的设想就是定时操作数据库,所以有很多实现方法,后来发现TimeJob可以同样实现我们的需求,而且更简便. 所以我们就使用了 ...
- .Net core使用Quartz.Net 实现定时任务
很多情况下,我们需要完成一些定时执行的功能,用很多定时工具,像:hangfire,TimeJob,以及Quartz.net,不过quartz.net 比较精确一些,功能也比较强大,所以我选择了Quar ...
- ASP.NET Core 使用 Hangfire 定时任务
定时任务组件,除了 Hangfire 外,还有一个 Quarz.NET,不过 Hangfire .NET Core 支持的会更好些. ASP.NET Core 使用 Hangfire 很简单,首先,N ...
- .NET Core 中基于 IHostedService 实现后台定时任务
.NET Core 2.0 引入了 IHostedService ,基于它可以很方便地执行后台任务,.NET Core 2.1 则锦上添花地提供了 IHostedService 的默认实现基类 Bac ...
随机推荐
- zshrc配置
大部分没有改动 # If you come from bash you might have to change your $PATH. # export PATH=$HOME/bin:/usr/lo ...
- 【js】vue 2.5.1 源码学习 (四) 钩子函数 资源选项 watch 的合并策略
大体思路 (三) 1.钩子函数 自定义策略 LIFECYCLE_HOOKS= [] created = [function(){} , function(){}] 组装方法 ...
- 2019-9-24-dotnet-remoting-使用事件
title author date CreateTime categories dotnet remoting 使用事件 lindexi 2019-09-24 15:39:26 +0800 2018- ...
- attr(),prop()二者区别和最佳实践
attr(),prop()二者区别和最佳实践 最近使用到attr()来获取自定义属性值,我印象中是有一个方法可以获取到自定义属性值,进而我又想到了另一个方法prop(). 查看了手册发现并没有对二者 ...
- Team Foundation Server 2015使用教程【5】:默认团队checkin权限修改
- 循环语句作业与循环补充(continue与break)
作业: 1.使用while循环输入1 2 3 4 5 6 8 9 10(没有7) n = 1 while n < 11: if n == 7: pass else: print(n) n = n ...
- ELK学习实验002:Elasticsearch介绍及单机安装
一 简介 ElasticSearch是一个基于Luncene的搜索服务器.它提供了一个分布式多用户能力全文搜索引擎,基于RESTful web接口,ElsticSearch使用Java开发的,并作为A ...
- Mysql 最全查询语句
基本查询语句及语法: select distinct from where group by having limit 一.单表查询 前期表与数据准备: # 创建一张部门表 create table ...
- cookies 与session
cookies :存放在浏览器(客户端)的用户信息 - 优点: 可以将数据存在客户端一方: - 缺点: 不安全,可以存放多份,导致服务端占用空间过大 session :存放在服务端的用户信息 - 优点 ...
- Java高级特性——流
以上就是这段时间学习完流的知识以后我的总结,.mmap文件可以去我的github上获取:https://github.com/xiaozhengyu/StudyNotes.git