Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    MicroThread Class

    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).

    System.Object → MicroThread
    Derived from MicroThread:

    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.

    | Improve this Doc View Source

    Constructors


    MicroThread(Scheduler, MicroThreadFlags)

    public MicroThread(Scheduler scheduler, MicroThreadFlags flags = MicroThreadFlags.None)
    Parameters
    Type Name Description
    Scheduler scheduler
    MicroThreadFlags flags
    | Improve this Doc View Source

    Fields


    Tags

    Gets the attached properties to this component.

    public PropertyContainer Tags
    Field Value
    Type Description
    PropertyContainer
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.


    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation