Fibrous 7.0.0

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

Banner

Fibrous

NuGet

High performance concurrency library for the .NET platform. Fibrous is a fork of Retlang [http://code.google.com/p/retlang/].

Fibrous is an actor-like framework and also a flexible and pragmatic concurrency toolbox. The main abstractions are Fibers (execution contexts), Channels (messaging conduits and endpoints), Scheduling, and Events (wrapped, subscribable .NET events). From these components, you can build simple to complex concurrent libraries and applications.

Some of the library benefits:

  • Tiny library that makes multi-threading easier to reason about
  • Thread-safe publishing
  • Single or multiple subscribers
  • Request/reply
  • UI fibers for worry-free UI marshalling
  • Batching support
  • Scheduling support (cron, DateTime, and TimeSpan based)

Fibrous is a good fit when you want in-process concurrency with clear ordering semantics without moving to a full distributed actor framework. It has been used in trading systems, server-side components, and desktop front ends.

If you need distributed concurrency, look into Akka.NET or Proto.Actor. If you need extreme low latency and highly specialized lock-free structures, look into Disruptor-like approaches instead.

Packages

  • Fibrous Core library with fibers, channels, request/reply, batching, scheduling, and events.
  • Fibrous.WPF WPF-specific dispatcher fiber and view model helpers.

Install with:

dotnet add package Fibrous
dotnet add package Fibrous.WPF

Supported Frameworks

Fibrous

  • .NET Standard 2.0
  • .NET 8
  • .NET 10

Fibrous.WPF

  • .NET 8-windows
  • .NET 10-windows

Core Concepts

Fibers

Fibers are ordered execution contexts. A single fiber processes one work item at a time, which makes it practical to keep state behind that fiber without adding your own locking around every mutation.

While a fiber processes sequentially, a system can still use many fibers in parallel and connect them with channels.

Fibers also own child disposables. Subscriptions and timers added through a fiber are cleaned up when the fiber is disposed.

There are specialized fibers for WPF, which marshal work to the dispatcher thread, and a StubFiber for testing and special cases where inline execution is acceptable.

public interface IFiber : IScheduler, IDisposableRegistry
{
    void Enqueue(Action action);
    void Enqueue(Func<Task> action);
}

Example:

IFiber fiber = new Fiber();

fiber.Enqueue(SomeParameterlessMethod);
fiber.Enqueue(() => DoSomeWork(someParam));

fiber.Schedule(ScheduledMethod, TimeSpan.FromSeconds(5));
fiber.Schedule(ScheduledMethod, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(10));

Channels and Ports

Ports are the endpoints for publishing and subscribing to messages.

The main port types are:

  • ISubscriberPort<T>
  • IPublisherPort<T>
  • IRequestPort<TRequest, TReply>
  • ISnapshotSubscriberPort<T, TSnapshot>
  • IEventPort
  • IEventTrigger

Channels are the in-memory conduits that implement those ports.

Built-in channel types include:

  • Channel<T> for normal pub/sub
  • QueueChannel<T> for work distribution to one of multiple subscribers
  • RequestChannel<TRequest, TReply> for request/reply
  • SnapshotChannel<T, TSnapshot> for initial snapshot plus later updates
  • StateChannel<T> for last-value replay

Events

Fibrous also includes simple event wrappers and helpers for subscribing fibers to Action and Action<T> based .NET events.

Important Semantics

  • Publishing to channels is thread-safe.
  • Handlers subscribed through a fiber run on that fiber.
  • Ordering is guaranteed per fiber, not across the whole system.
  • Disposing a fiber disposes child subscriptions and scheduled work that it owns.
  • Batching and last-message subscribers are time-based coordination helpers built on top of fibers and channels.
  • Filtered subscribe is publisher-side only for ports that support inline subscription. This avoids queueing discarded messages but is a more advanced path than normal fiber subscription.

Basic Examples

Channel

IFiber fiber = new Fiber();
Channel<string> channel = new();

channel.Subscribe(fiber, msg => Console.WriteLine(msg.ToUpperInvariant()));
channel.Publish("the message");

Create and Subscribe in One Line

IFiber fiber = new Fiber();

IChannel<string> channel = fiber.NewChannel<string>(msg => Console.WriteLine(msg.ToUpperInvariant()));
channel.Publish("the message");

Request / Reply

IFiber serverFiber = new Fiber();
IFiber clientFiber = new Fiber();

RequestChannel<int, string> channel = new();

channel.SetRequestHandler(serverFiber, request =>
{
    request.Reply($"value:{request.Request}");
    return Task.CompletedTask;
});

channel.SendRequest(42, clientFiber, reply =>
{
    Console.WriteLine(reply);
    return Task.CompletedTask;
});

You can also await replies directly:

string reply = await channel.SendRequestAsync(42);
Reply<string> timedReply = await channel.SendRequestAsync(42, TimeSpan.FromSeconds(2));

Queue Channel

IFiber worker1 = new Fiber();
IFiber worker2 = new Fiber();
QueueChannel<int> queue = new();

queue.Subscribe(worker1, x => Console.WriteLine($"worker1:{x}"));
queue.Subscribe(worker2, x => Console.WriteLine($"worker2:{x}"));

queue.Publish(1);
queue.Publish(2);
queue.Publish(3);

Each message is delivered to one subscriber, not all subscribers.

State Channel

StateChannel<string> state = new("starting");
IFiber fiber = new Fiber();

state.Subscribe(fiber, value =>
{
    Console.WriteLine(value);
    return Task.CompletedTask;
});

state.Publish("running");

A new subscriber immediately receives the latest value if one exists.

Snapshot Channel

SnapshotChannel<string, string[]> channel = new();
IFiber fiber = new Fiber();

channel.ReplyToPrimingRequest(fiber, () => Task.FromResult(new[] { "a", "b" }));

channel.Subscribe(
    fiber,
    update => Console.WriteLine($"update:{update}"),
    snapshot =>
    {
        Console.WriteLine(string.Join(",", snapshot));
        return Task.CompletedTask;
    });

WPF

Fibrous.WPF provides DispatcherFiber, which marshals work to the WPF dispatcher thread.

DispatcherFiber fiber = new(error => Console.WriteLine(error));

fiber.Enqueue(() =>
{
    StatusText = "Updated on the UI thread";
});

Common Patterns

Agent

Agents wrap a fiber and a handler to give a lightweight actor-like API.

var agent = new Agent<string>(msg =>
{
    Console.WriteLine(msg.ToUpperInvariant());
    return Task.CompletedTask;
}, error => {});

agent.Publish("the message");

Batch and Last

Fibrous has helpers for:

  • periodic batches
  • keyed periodic batches
  • last-message-per-interval delivery

These are useful when UI or downstream systems should not process every individual message immediately.

Event Bus

EventBus<T> gives a static global channel by type.

EventBus<string>.Subscribe(fiber, msg => Console.WriteLine(msg));
EventBus<string>.Publish("the message");

Use a normal Channel<T> when explicit ownership is important.

Disposal and Lifetime

Most applications should treat fibers as the main ownership boundary.

  • create subscriptions and schedules through a fiber
  • dispose the fiber when that subsystem is done
  • prefer keeping mutable state behind a single owning fiber

Example:

using IFiber fiber = new Fiber();
using Channel<int> channel = new();

channel.Subscribe(fiber, x => Console.WriteLine(x));
channel.Publish(1);

Notes on Cron Scheduling

Fibrous includes cron scheduling support without taking an external Quartz package dependency. The cron expression format follows Quartz-style expressions.

For most scheduling needs, TimeSpan and repeated scheduling are simpler and easier to reason about. Use cron when you really need calendar-style schedules.

When Fibrous Is a Good Fit

  • in-process concurrency
  • desktop applications
  • message-driven application components
  • trading-style shared state and coordination
  • replacing ad hoc locking with clearer execution ownership
  • mixing scheduling and other concurrency/messaging needs

When Fibrous Is Probably Not the Right Tool

  • distributed actors
  • durable workflow/orchestration
  • extremely specialized ultra-low-latency systems
  • scenarios that need built-in persistence or cluster coordination

Tests and Examples

The test suite covers the main semantics of ordering, request/reply, batching, state/snapshot behavior, scheduling, and cleanup. The examples and tests are good places to look when you want to see a particular pattern in use.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 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 is compatible.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Fibrous:

Package Downloads
Fibrous.WPF

High performace concurrency library for the .Net platform.

Fibrous.Proxy

Automatic fiber based proxy generation

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.0.0 4,952 6/21/2026
7.0.0-preview.1 101 4/16/2026
6.1.0 3,661 12/27/2024
6.0.0 222 12/8/2024
5.1.0 62,029 10/29/2023
5.0.0 3,035 5/27/2021
4.1.0 9,563 8/8/2020
4.0.0 5,310 4/18/2020
3.2.0 2,057 1/9/2020
3.1.0 920 12/18/2019
3.0.5 821 12/2/2019
3.0.4 1,266 11/21/2019
3.0.3-beta 795 11/19/2019
3.0.2-beta 759 11/19/2019
3.0.1-beta 770 11/17/2019
3.0.0-beta 807 11/17/2019
2.1.0 1,500 9/19/2019
2.0.0 3,712 3/4/2018
2.0.0-beta 1,615 2/4/2018
1.0.8 1,692 12/19/2015
Loading failed