SfeWork.TimedJob
2.0.5
dotnet add package SfeWork.TimedJob --version 2.0.5
NuGet\Install-Package SfeWork.TimedJob -Version 2.0.5
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="SfeWork.TimedJob" Version="2.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SfeWork.TimedJob" Version="2.0.5" />
<PackageReference Include="SfeWork.TimedJob" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SfeWork.TimedJob --version 2.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SfeWork.TimedJob, 2.0.5"
#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.
#:package SfeWork.TimedJob@2.0.5
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SfeWork.TimedJob&version=2.0.5
#tool nuget:?package=SfeWork.TimedJob&version=2.0.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
简单的定时任务组件
1、快速开始
var jobService = new SfeWork.TimedJob();
object state = "args";
//间隔10秒执行一次
jobService.Set(CallBack, state, 10);
//每天20点30分00秒执行一次
jobService.Set(CallBack, state, 20, 30);
//每月10号20点30分00秒执行一次
jobService.Set(CallBack, state, 10, 20, 30);
//每周周一20点30分00秒执行一次
jobService.Set(CallBack, state, TimedJob.Week.周一, 20, 30);
jobService.Start();
2、支持同步和异步回调
public void main()
{
var jobService = new SfeWork.TimedJob();
object state = "args";
//可以设置同步回调方法
jobService.Set(CallBack, state, 10);
//可以设置异步回调方法
jobService.Set(CallBackAsync, state, 10);
jobService.Start();
}
public void CallBack(object? state)
{
Console.WriteLine(object);
}
public async Task CallBackAsync(object? state)
{
Console.WriteLine(object);
await Task.CompletedTask;
}
3、注意:定时任务的下次执行时间计算
- 比如设定每3秒执行一次,任务需要5秒才能执行完成,假如首次执行是在00秒,下次执行会是在08秒。
- 比如设定每3秒执行一次,任务需要2秒才能执行完成,假如首次执行是在00秒,下次执行会是在03秒。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.5 | 85 | 2/18/2026 |