BetterTasks 1.0.2
dotnet add package BetterTasks --version 1.0.2
NuGet\Install-Package BetterTasks -Version 1.0.2
<PackageReference Include="BetterTasks" Version="1.0.2" />
<PackageVersion Include="BetterTasks" Version="1.0.2" />
<PackageReference Include="BetterTasks" />
paket add BetterTasks --version 1.0.2
#r "nuget: BetterTasks, 1.0.2"
#:package BetterTasks@1.0.2
#addin nuget:?package=BetterTasks&version=1.0.2
#tool nuget:?package=BetterTasks&version=1.0.2
BetterTasks
A rewrite of the C# Task system. Performs about 10% faster than the built-in Task system.
Installation
Add the .dll file as a dependency for your project.
Usage
Import the package:
using BetterTasks;
There are two ways to create and run a BetterTask:
BetterTask task = new BetterTask(() => Console.WriteLine("Hello World!"));
task.Start();
or
BetterTask task = BetterTask.Run(() => Console.WriteLine("Hello World!"));
BetterTask is designed to work as similarly as possible to Task. .ContinueWith(Action action)
and .Wait()
both work. However, it has a few extra features:
Passing the Task as a Parameter<br> When passing a delegate to a BetterTask, it can take a parameter that will be the BetterTask.
BetterTask.Run((task) => Console.WriteLine(task));
Abort<br>
BetterTask can be aborted with the .Abort()
method.
Cancel<br>
BetterTask can be cancelled with the .Cancel()
method. The IsCanceled
property will be true after this method is called. Actions should check if IsCanceled
is true and shut down if it is.
ForceCancel<br>
The .ForceCancel(int timeout = 2000)
method calls .Cancel()
, then after timeout
milliseconds, if the task has not shut down, calls .Abort()
.
Task Priority<br>
BetterTask's constructors have an optional parameter, priority
, of type ThreadPriority
, which defaults to ThreadPriority.Normal
. Whichever thread executes the task will be set to this priority while executing the task.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. |
-
net8.0
- 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.