MicroThread Class
Namespace: Stride.Core.MicroThreadingAssembly: 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
Name | Description | |
---|---|---|
Constructors | ||
MicroThread(Scheduler, MicroThreadFlags) | ||
Fields | ||
Tags | Gets the attached properties to this component. |
|
Properties | ||
CancellationToken | A token for listening to the cancellation of the MicroThread. |
|
Current | Gets the current micro thread (self). |
|
Exception | Gets the exception that was thrown by this MicroThread. |
|
Flags | Gets the MicroThread flags. |
|
Id | Gets the id of this MicroThread. |
|
IsOver | Indicates whether the MicroThread is terminated or not, either in Completed, Canceled or Failed status. |
|
Name | Gets or sets the name of this MicroThread. |
|
Priority | Gets or sets the priority of this MicroThread. |
|
ScheduleMode | Gets or sets the MicroThread scheduling mode. |
|
Scheduler | Gets the scheduler associated with this MicroThread. |
|
State | Gets the state of this MicroThread. |
|
Methods | ||
Cancel() | Cancels the MicroThread. |
|
Migrate(Scheduler) | ||
Remove() | ||
Run() | Yields to this MicroThread. |
|
Start(Func<Task>, ScheduleMode) | Starts this MicroThread with the specified function. |
Constructors
MicroThread(Scheduler, MicroThreadFlags)
public MicroThread(Scheduler scheduler, MicroThreadFlags flags = MicroThreadFlags.None)
Parameters
Type | Name | Description |
---|---|---|
Scheduler | scheduler | |
MicroThreadFlags | flags |
Fields
Tags
Gets the attached properties to this component.
public PropertyContainer Tags
Field Value
Type | Description |
---|---|
PropertyContainer |
Properties
CancellationToken
A token for listening to the cancellation of the MicroThread.
public CancellationToken CancellationToken { get; }
Property Value
Type | Description |
---|---|
System.Threading.CancellationToken |
Current
Gets the current micro thread (self).
public static MicroThread Current { get; }
Property Value
Type | Description |
---|---|
MicroThread | The current micro thread (self). |
Exception
Gets the exception that was thrown by this MicroThread.
public Exception Exception { get; }
Property Value
Type | Description |
---|---|
System.Exception | The exception. |
Flags
Gets the MicroThread flags.
public MicroThreadFlags Flags { get; }
Property Value
Type | Description |
---|---|
MicroThreadFlags | The flags. |
Id
Gets the id of this MicroThread.
public long Id { get; }
Property Value
Type | Description |
---|---|
System.Int64 | The id. |
IsOver
Indicates whether the MicroThread is terminated or not, either in Completed, Canceled or Failed status.
public bool IsOver { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Name
Gets or sets the name of this MicroThread.
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name. |
Priority
Gets or sets the priority of this MicroThread.
public long Priority { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 | The priority. |
ScheduleMode
Gets or sets the MicroThread scheduling mode.
public ScheduleMode ScheduleMode { get; set; }
Property Value
Type | Description |
---|---|
ScheduleMode | The scheduling mode. |
Scheduler
Gets the scheduler associated with this MicroThread.
public Scheduler Scheduler { get; }
Property Value
Type | Description |
---|---|
Scheduler | The scheduler associated with this MicroThread. |
State
Gets the state of this MicroThread.
public MicroThreadState State { get; }
Property Value
Type | Description |
---|---|
MicroThreadState | The state of this MicroThread. |
Methods
Cancel()
Cancels the MicroThread.
public void Cancel()
Migrate(Scheduler)
public void Migrate(Scheduler scheduler)
Parameters
Type | Name | Description |
---|---|---|
Scheduler | scheduler |
Remove()
public void Remove()
Run()
Yields to this MicroThread.
public async Task Run()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | Task. |
Start(Func<Task>, ScheduleMode)
Starts this MicroThread with the specified function.
public void Start(Func<Task> microThreadFunction, ScheduleMode scheduleMode = ScheduleMode.Last)
Parameters
Type | Name | Description |
---|---|---|
System.Func<System.Threading.Tasks.Task> | microThreadFunction | The micro thread function. |
ScheduleMode | scheduleMode | The schedule mode. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | MicroThread was already started before. |