StartupTasks 1.0.5
dotnet add package StartupTasks --version 1.0.5
NuGet\Install-Package StartupTasks -Version 1.0.5
<PackageReference Include="StartupTasks" Version="1.0.5" />
paket add StartupTasks --version 1.0.5
#r "nuget: StartupTasks, 1.0.5"
// Install StartupTasks as a Cake Addin
#addin nuget:?package=StartupTasks&version=1.0.5
// Install StartupTasks as a Cake Tool
#tool nuget:?package=StartupTasks&version=1.0.5
StartupTasks
About The Project
This is a simple library written in C# .NET 6 for adding startup tasks using hosted services.
Getting Started
Add the nuget package reference to your project
- Using dotnet-cli
dotnet add package StartupTasks
- Using Package Manager
Install-Package StartupTasks
Create as class that implements IStartupTask
public class MyStartupTask : IStartupTask
{
public Task RunAsync(CancellationToken cancellationToken)
{
// Startup logic goes here
return Task.CompletedTask;
}
}
Register startup tasks with IServiceCollection
and add your startup task. Code block below shows common usage scenarios.
using StartupTasks;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddStartupTasks()
// Adds a startup task that runs first.
.Add<MyStartupTask>();
// Adds another startup task that runs second.
.Add<AnotherStartupTask>();
// Adds a startup task that runs in parlallel
// and begins before the sequential tasks are
// executed.
.Add<ParallelStartupTask>(runInParllel: true)
// Adds a startup task without a class file.
// Delegate takes a CancellationToken as parameter
// and returns a Task.
.AddAction(async (cancellationToken) =>
await Console.out.WriteLineAsync("Let's begin", cancellationToken),
runInParallel: true)
var app = builder.Build();
app.Run();
Roadmap
- Add startup tasks executed in hosted services
- Add startup task health check report after all have ran
- Add option to verification of registered tasks can be resolved at before execution
- Add startup groups so that groups of startup tasks can run sequentially within it's group but in parallel with other groups
See the open issues for a full list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Albin Ma - ama@almatek.io
Project Link: https://github.com/almatek/dotnet-startup-tasks
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. |
-
net6.0
- Microsoft.Extensions.Hosting.Abstractions (>= 6.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.