JobQueue 1.0.0

dotnet add package JobQueue --version 1.0.0
                    
NuGet\Install-Package JobQueue -Version 1.0.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="JobQueue" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="JobQueue" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="JobQueue" />
                    
Project file
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 JobQueue --version 1.0.0
                    
#r "nuget: JobQueue, 1.0.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.
#:package JobQueue@1.0.0
                    
#: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=JobQueue&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=JobQueue&version=1.0.0
                    
Install as a Cake Tool

JobQueue

JobQueue is a lightweight, thread-based sequential task execution library for .NET.
It lets you enqueue tasks that are guaranteed to be processed in order by a dedicated background thread — ideal for scenarios like message handling, background jobs, or serialized I/O operations.


✨ Features

  • ✅ Thread-safe sequential job execution
  • ✅ Dedicated background processing thread
  • ✅ Simple and expressive API
  • ✅ Built-in control methods (Start, Suspend, Resume, Cancel, etc.)
  • ✅ Error event handling

📦 Installation

dotnet add package JobQueue

🚀 Quick Start

// 1. Create a JobQueue that receives byte[] and processes it using OnReceiveMessage
var messages = new JobQueue<byte[]>("ReceiveMessage", OnReceiveMessage);

// 2. Subscribe to error events
messages.Error += (_, args) => logger.Error(args.Exception, "ReceiveMessage");

// 3. Push a job into the queue
messages.Push(e.Packet);

⏱ Scheduled Jobs

If you need a job to run periodically or with delay, use the JobBuilder:

var connectionJob = JobBuilder
    .Create()
    .Schedule(TimeSpan.FromSeconds(3)) // Delay
    .OnAction(OnConnectionJob)         // Delegate to run
    .Build();

🧠 Lifecycle Control

You can start, stop or pause the queue anytime:

messages.Start();              // Starts the worker
messages.Suspend();            // Pauses job processing
messages.Resume();             // Resumes after suspension
messages.Cancel();             // Gracefully cancels the queue
messages.Join();               // Waits until all jobs are done
messages.Wait(TimeSpan.FromSeconds(10));  // Waits with timeout

📌 Event Handling

Subscribe to error events to catch exceptions thrown by job handlers:

messages.Error += (_, args) =>
{
    Console.WriteLine($"Error occurred: {args.Exception.Message}");
};

🧪 Example Use Cases

  • Message processing (e.g., MQ, WebSocket)
  • Sequential file/database writes
  • Rate-limited API calls
  • Retry or delayed job handling

📃 License

MIT — see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  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 is compatible.  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 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.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.

Version Downloads Last Updated
1.0.0 296 6/23/2025

Initial release of JobQueue.  
- Thread-based sequential job execution  
- Background task processing  
- Easy callback registration