logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class SampleDelayTask

    A sample task that introduces a delay for demonstration or testing purposes.

    Inheritance
    object
    SampleDelayTask
    Implements
    ITask
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Tasking.Application.Tasks
    Assembly: Serenity.Global.Application.dll
    Syntax
    public class SampleDelayTask : ITask
    Remarks

    This task is useful for simulating work or waiting periods in task execution flows.

    Constructors

    SampleDelayTask(string, int, TaskCriticality, float)

    Initializes a new instance of the SampleDelayTask class.

    Declaration
    public SampleDelayTask(string id, int ms, TaskCriticality criticality = 1, float weight = 1)
    Parameters
    Type Name Description
    string id

    The unique identifier for the task.

    int ms

    The delay duration in milliseconds.

    TaskCriticality criticality

    The criticality level of the task. Default is Degradable.

    float weight

    The weight of the task. Default is 1. Must be greater than 0.

    Properties

    Criticality

    Criticality level of the task.

    Declaration
    public TaskCriticality Criticality { get; }
    Property Value
    Type Description
    TaskCriticality

    The criticality level.

    Id

    Unique identifier for the task.

    Declaration
    public string Id { get; }
    Property Value
    Type Description
    string

    The unique identifier as a string.

    LastError

    Gets the last error that occurred during task execution, if any.

    Declaration
    public Exception LastError { get; }
    Property Value
    Type Description
    Exception

    The last exception encountered, or null if none.

    Weight

    Weight of the task, influencing its scheduling and resource allocation.

    Declaration
    public float Weight { get; }
    Property Value
    Type Description
    float

    The weight of the task.

    Methods

    RunAsync(CancellationToken)

    Runs the task asynchronously, introducing a delay for the specified duration.

    Declaration
    public Task RunAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    A token to monitor for cancellation requests.

    Returns
    Type Description
    Task

    A task that represents the asynchronous operation.

    Implements

    ITask
    In this article
    © 2026 Serenity. All Rights Reserved