Invoke() at 0f time (immediately) is not safe

Hello,

searched a bit but didn’t see any warning topic about it :

The Invoke(string methodName, float time) method is not safe when time is set at 0f (= supposed to be immediately).
There is a micro delay (like 5 ms) that could create some disorder in your code execution plan, if you’re using it before a block of code for example, while counting on this block to have a priority over your Invoke.

It might come from the fact that Invoke is runtime, unlike a compiled native function, I don’t know.

Anyway, just wanted to warn you about that, using Delegates should be safer I guess.

(until I’m wrong)

I’ve mentioned it before; I always use something like .001 instead of 0.

No, because you can call the same function without using Invoke and it will run immediately.

–Eric

Great, thanks for the tip Eric.