Asc.Utils.Needle
1.0.1
dotnet add package Asc.Utils.Needle --version 1.0.1
NuGet\Install-Package Asc.Utils.Needle -Version 1.0.1
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="Asc.Utils.Needle" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Asc.Utils.Needle --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Asc.Utils.Needle, 1.0.1"
#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 Asc.Utils.Needle as a Cake Addin
#addin nuget:?package=Asc.Utils.Needle&version=1.0.1
// Install Asc.Utils.Needle as a Cake Tool
#tool nuget:?package=Asc.Utils.Needle&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Asc.Utils.Needle
Utility to simplify multithreading background operations
Installation
Install-Package Asc.Utils.Needle
Usage
With using statement
IResult someResult = null;
using INeddleWorker neddleWorker = Pincushion.Instance.GetNeedle();
neddleWorker.AddJob(SomeVoidMethod);
neddleWorker.AddJob(SomeAsyncTaskMethod);
neddleWorker.AddJob(async () => await DoSomethingAsync());
if (someCondition)
neddleWorker.AddJob(() => { someResult = GetResult(); });
await neddleWorker.RunAsync();
Without using statement
IResult someResult = null;
INeddleWorker neddleWorker = Pincushion.Instance.GetNeedle(maxThreads: 2);
neddleWorker.AddJob(SomeVoidMethod);
neddleWorker.AddJob(SomeAsyncTaskMethod);
neddleWorker.AddJob(async () => await DoSomethingAsync());
if (someCondition)
neddleWorker.AddJob(() => { someResult = GetResult(); });
needleWorker.Completed += (object sender, EventArgs e) => needleWorker.Dispose();
neddleWorker.BeginRun();
If some job fails
using INeddleWorker neddleWorker = Pincushion.Instance.GetNeedle(
maxThreads: 2,
cancelPendingJobsIfAnyOtherFails: false
);
foreach(Action job in jobs)
neddleWorker.AddJob(job);
try
{
await neddleWorker.RunAsync();
}
catch (AggregateException aggregateEx)
{
foreach (Exception exception in aggregateEx.InnerExceptions)
logger.LogException(exception);
}
catch (Exception ex)
{
logger.LogException(ex, "Unexpected error while INeddleWorker.RunAsync");
}
More info
See INeddleWorker interface to get more info about how to use this utility
Icon from Flaticon:
<a href="https://www.flaticon.com/free-icons/sew" title="sew icons">Sew icons created by Pixel perfect - Flaticon</a>
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
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.
Fixed a bug wich causes to not be able of check por INeddleWorker progress due to a INotifyPropertyChanged missing reference