Alternative for the Invoke function of Unity?

Hey, so I came from Unity to Xenko and am a decent Unity C# programmer. So far, I felt like at home when using Xenko. Yet I never really touched timers, as Unity did provide those awesome Invoke functions. Now I come here to ask if there is a similiar feature in Xenko? I would be very thankful if someone would tell me!

What can you do with that feature? I’m not familiar with that, since I don’t have much experience with unity

Last time I heard about it, it was considered an obsolete API and recommended to use coroutines instead.

Anyway what you are looking for could be to use an async method with some Task.Delay() calls.

Such as

public async Task Invoke(Action action, TimeSpan delay)
{
    await Task.Delay(delay);
    action();
}
2 Likes

Ah, if it’s just for timing, Xenko is much nicer to work with in that regard.

Since Xenko is using the official .NET runtime and you can use latest C# features, async/await is the way to go, as Kryptos said.

1 Like

Ah, okay, thank you!
I will look into iit and try it out!
Thanks again!