Table of Contents

Class MicroThread

Namespace
Stride.Core.MicroThreading
Assembly
Stride.Core.MicroThreading.dll

Represents an execution context managed by a Scheduler, that can cooperatively yield execution to another MicroThread at any point (usually using async calls).

public class MicroThread
Inheritance
MicroThread

Constructors

MicroThread(Scheduler, MicroThreadFlags)

public MicroThread(Scheduler scheduler, MicroThreadFlags flags = MicroThreadFlags.None)

Parameters

scheduler Scheduler
flags MicroThreadFlags

Fields

Tags

Gets the attached properties to this component.

public PropertyContainer Tags

Field Value

PropertyContainer

Properties

CancellationToken

A token for listening to the cancellation of the MicroThread.

public CancellationToken CancellationToken { get; }

Property Value

CancellationToken

Current

Gets the current micro thread (self).

public static MicroThread Current { get; }

Property Value

MicroThread

The current micro thread (self).

Exception

Gets the exception that was thrown by this MicroThread.

public Exception Exception { get; }

Property Value

Exception

The exception.

Flags

Gets the MicroThread flags.

public MicroThreadFlags Flags { get; }

Property Value

MicroThreadFlags

The flags.

Id

Gets the id of this MicroThread.

public long Id { get; }

Property Value

long

The id.

IsOver

Indicates whether the MicroThread is terminated or not, either in Completed, Canceled or Failed status.

public bool IsOver { get; }

Property Value

bool

Name

Gets or sets the name of this MicroThread.

public string Name { get; set; }

Property Value

string

The name.

Priority

Gets or sets the priority of this MicroThread.

public long Priority { get; set; }

Property Value

long

The priority.

ScheduleMode

Gets or sets the MicroThread scheduling mode.

public ScheduleMode ScheduleMode { get; set; }

Property Value

ScheduleMode

The scheduling mode.

Scheduler

Gets the scheduler associated with this MicroThread.

public Scheduler Scheduler { get; }

Property Value

Scheduler

The scheduler associated with this MicroThread.

State

Gets the state of this MicroThread.

public MicroThreadState State { get; }

Property Value

MicroThreadState

The state of this MicroThread.

Methods

Cancel()

Cancels the MicroThread.

public void Cancel()

Migrate(Scheduler)

public void Migrate(Scheduler scheduler)

Parameters

scheduler Scheduler

Remove()

public void Remove()

Run()

Yields to this MicroThread.

public Task Run()

Returns

Task

Task.

Start(Func<Task>, ScheduleMode)

Starts this MicroThread with the specified function.

public void Start(Func<Task> microThreadFunction, ScheduleMode scheduleMode = ScheduleMode.Last)

Parameters

microThreadFunction Func<Task>

The micro thread function.

scheduleMode ScheduleMode

The schedule mode.

Exceptions

InvalidOperationException

MicroThread was already started before.