ConfigureAwait(this) shouldn't run the continuation if the owner is destroyed. · Issue #1 · muckSponge/UnityAsync · GitHub
Skip to content

ConfigureAwait(this) shouldn't run the continuation if the owner is destroyed. #1

Description

@mikehofm

Love your library!

Say you have some code like this:

async void Start()
{
    await Await.Seconds(5).ConfigureAwait(this);
    transform.position = new Vector3(1, 2, 3);  // will crash if object was destroyed
}

Currently, if the GameObject or Component is destroyed, the continuation runs immediately, which would cause a crash. I think it would be more intuitive if the continuation were cancelled instead. This is probably what the user wants most of the time and is consistent with how coroutines work.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions