Table of Contents

Fibers Class

public abstract class Fibers

An abstract base class for managing concurrent asynchronous operations, often referred to as "fibers" or "lightweight threads."

Inheritance
Fibers
Derived
Fibers<TSource, TValue>
Extension Methods

Fields

NIL
Result_Default
Result_MustNotBeReached
b_concurrency
b_errorHandler

A delegate that handles exceptions occurring within the fiber.

needLock_runningTasks

A non-thread-safe list to keep track of currently running tasks.

sync_runningTasks
taskSource

The TaskCompletionSource used to manage the completion state of the fiber.

Properties

Concurrency

Gets or sets the maximum number of concurrent tasks allowed.

IsCompleted

Gets a value indicating whether the fiber has completed its execution.

IsFailed

Gets a value indicating whether the fiber has encountered an unhandled exception.

IsRunning

Gets a value indicating whether the fiber is actively processing tasks.

State

Gets or sets an arbitrary object that can be used to store state information.

Methods

AsTask()

Returns the underlying Task that represents the asynchronous operation of the fiber.

ForEach<TSource, TResult>(int, IEnumerable<TSource>, Func<TSource, Task<TResult>>)

Creates a new Fibers<TSource, TValue> instance for processing a collection of items.

For<TResult>(int, int, int, int, Func<int, Task<TResult>>)

Creates a new Fibers<TSource, TValue> instance for processing a range of integers.

GetAwaiter()

Gets an awaiter for this fiber, allowing it to be awaited. Automatically starts the fiber if it hasn't been started yet.

SetErrorHandler(Func<Exception, Fibers, ErrorReason, ErrorHandlingPolicy>?)

Sets the error handler for the fiber.

Start()

Starts the execution of the fiber. If the fiber is already running, it returns the existing active task.

Stop()

Stops the execution of the fiber and waits for currently running background tasks to complete.