Aicrosoft.Scheduling
6.4.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Aicrosoft.Scheduling --version 6.4.0
NuGet\Install-Package Aicrosoft.Scheduling -Version 6.4.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aicrosoft.Scheduling" Version="6.4.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aicrosoft.Scheduling --version 6.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Aicrosoft.Scheduling, 6.4.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Aicrosoft.Scheduling as a Cake Addin #addin nuget:?package=Aicrosoft.Scheduling&version=6.4.0 // Install Aicrosoft.Scheduling as a Cake Tool #tool nuget:?package=Aicrosoft.Scheduling&version=6.4.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Aicrosoft.Scheduling
简单的多功能可扩展的任务调度框架 A multifunctional and extensible task scheduling framework Keywords: superjobs,task,job,routine,schedule,startup,interval,cronexpression
SuperJobs
简单的多功能可扩展的任务调度实现 它同时也是一个示例与参考
使用说明 How To Use
一个具体的Task三部分组成:
- SomeJob : Job, ITransient : 必须,它是该Job任务的配置信息,名称,运行时间,等。可以是硬编码,也可以是在Appsettings.json中的配置。
- SomeWorker : TimerWorker, ITransient :不须一一对应,但是要有给Job可用的。不同类型的Job,如果执行的任务是同一类型的,可以由同样的Worker来运行。
- SomeWorkerPoolProvider : WorkerPoolProvider<SomeWorker>, ITransient :它与具体的Worker一一对应。池化具体的Worker。
具体的工作负载都是在SomeWorker.ExecuteAsync(CancellationToken)中来完成的。请注意任务的取消,以便急时取消任务。
关于扩展
配置的扩展
单独独立插件式Job的程序集
- 单独的程序集Job必须以 xxxJob来命名。
- 每个Job程序集中可以有多个Job,可以有自已的配置文件(不要与其它的程序集里的配置文件名相同即可)。继承JobAppSetupBase重写相关方法即可注册服务类或配置绑定。
- 程序集Job 项目属性里要加上 <EnableDynamicLoading>true</EnableDynamicLoading> 以便将所有的包的dll都拷贝过去。
- 在Build PostEvent里加上脚本: call "$(ProjectDir)..\SuperJobsAgent\copyjobs.bat" "$(ProjectName)" "$(TargetDir)" "$(AssemblyName)"
关于Woker的使用的注意事项
- 绝大数多数情况下,不用直接继承Worker。除非该Worker是立即运行;
- 通过Task.Delay方式运行的方法并没有Timer的调用更高效,所以当前框架使用的是Timer;
- TimerWorker有很多Protected方法实现了相关事件的调用;
- dotnet6已经没有AppDomain的隔离方式了。
- 示例项目 SuperJobsAgent.Console 引入Fody后开发中不能急时生成开发的内容,最好是仅在Release中使用。
- 示例项目中的公有资源配置及配置的Job信息移除,采用Job程序集中独立配置文件获取(注意不同Job的配置文件不要同名)。
- 如何一个任务是一直运行模式,可以以一Job来触发它的另一个Worker,这个是个可以改进的地方。
SuperJobs Architecture Design
关于UML上Class创建与依赖的关系说明
- Instances are mostly created through DI through their interfaces.
- The interface instantiated by DI does not draw the relationship
- WorkShop 消费 Worker, WorkerPoolFactory 创建Woker。
关于UML 图及设计说明
- Job仅仅是对某一个任务的描述(名称,调度,由哪个Worker来运行等);
- Woker是执行Job的任务负载者。
- Job由两种已定义的JobProvider创建,这两个JobProvider能通过硬编码和配置设定Job信息,然后能过JobFactory汇总出所有的可用Jobs;
- Woker由WokerPoolProvider提供,然后由WokerPoolFactory汇总所有可用的Woker。自定义的Worker必须实现对应的WorkerPoolProvider;
工作要求类型(Worker.RequiredStyles)
- 该类型与Job的JobTrigger中的Style是有对应关系的;
- 该属性是个Flag枚举值;
- 只有Job的Trigger Style符合Worker的RequiredStyles才能调用;
Job的触发器
根据传入的Triger类型来生成触发器
- Default 通过其它的Woker来触发的Job,当下面的类型未检测到时转视为该类型 (目前没用到)
- Startup 大于0的延迟启动毫秒数,Int类型的数字 ex:1200 该Worker用完后将被完全释放;
- Interval 间隔运行的Job,Timespan类型 ex:00:01:00
负载运行时间不被算在间隔时间内
完成后回收到池; - Schedulable Cron表达式触发的Job,CronExpresssion表达式 ex:0 0/7 * * * ? 完成后回收到池中;
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- Aicrosoft.Extensions (>= 6.4.0)
- Aicrosoft.Extensions.AspectCore (>= 6.4.0)
- Aicrosoft.Extensions.Hosting (>= 6.4.0)
- Cronos (>= 0.7.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Aicrosoft.Scheduling:
Package | Downloads |
---|---|
SuperJobs.Core
Extensions of Aicrosoft Ltd. |
GitHub repositories
This package is not used by any popular GitHub repositories.