Baksteen.Async.TaskQueue 1.0.0

dotnet add package Baksteen.Async.TaskQueue --version 1.0.0
NuGet\Install-Package Baksteen.Async.TaskQueue -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="Baksteen.Async.TaskQueue" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Baksteen.Async.TaskQueue --version 1.0.0
#r "nuget: Baksteen.Async.TaskQueue, 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.
// Install Baksteen.Async.TaskQueue as a Cake Addin
#addin nuget:?package=Baksteen.Async.TaskQueue&version=1.0.0

// Install Baksteen.Async.TaskQueue as a Cake Tool
#tool nuget:?package=Baksteen.Async.TaskQueue&version=1.0.0


TaskQueue is a lightweight C# async implementation of a FIFO execution queue. It enables async queueing of async work that will be executed in guaranteed first-in first-out (FIFO) order. It is a fork of Gentlee's SerialQueue, but in this case the implementation is fully async based and maybe a bit easier to understand.


using Baksteen.Async;

class TaskQueue {
    Task Enqueue(Action action);
    Task<T> Enqueue<T>(Func<T> function);
    Task Enqueue(Func<Task> asyncAction);
    Task<T> Enqueue<T>(Func<Task<T>> asyncFunction);


readonly TaskQueue queue = new TaskQueue();

async Task SomeAsyncMethod()
    await queue.Enqueue(AsyncAction);
    var result = await queue.Enqueue(AsyncFunction);



Nesting and awaiting queue.Enqueue leads to deadlock in the queue:

var queue = new TaskQueue();

await queue.Enqueue(async () =>
  await queue.Enqueue(async () =>
    // This code will never run because it waits until the first task executes,
    // and first task awaits while this one finishes.
    // Queue is locked.

This particular case can be fixed by either not awaiting nested Enqueue or not putting nested task to queue at all, because it is already in the queue. Overall it is better to implement code not synced first, but later sync it in the upper layer that uses that code, or in a synced wrapper.

Product 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 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.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 289 1/11/2023

First release.