Skip to content

How to mimic TaskStatus.Running from C# Tasks in UniTasks? #643

@EricBatlleTripledot

Description

@EricBatlleTripledot

Hey, wonderful package, you deserve a monument for this.

I'm just wondering, UniTask have a lot of UniTaskStatus options, but I'm missing the equivalent to TaskStatus.Running, why? How can I try to know if a Task is Running? The only way I can think of is to do:

public static bool IsRunning(this UniTask uniTask)
{
    return uniTask.Status is not (UniTaskStatus.Canceled and UniTaskStatus.Faulted and UniTaskStatus.Pending and UniTaskStatus.Succeeded);
}

But this, by default it's imposible, cause there's no any other state :/

Could you suggest a better way? I need this to also work with Defered tasks, and this issue makes me think that maybe accessing and comparing Status is not the best way :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions