Call method only once

How can i create a trigger that calls a method only once without using a bool, and this from for example update?

For example when i use Invoke(method, interval) the invoke itself is constantly called.

Add the method to a multicast delegate, and remove the method from the delegate from within the method.

Example:

Action methodToRunOnce = () => Invoke(method, interval);
methodToRunOnce += () => HandleUpdate -= methodToRunOnce;
HandleUpdate += methodToRunOnce;

I don’t know of a way to do it more cleanly, if your modified action is a property…

void RunWithMethodNextTime(Func<Action> get, Action<Action> set, Action method, bool runAtBeginning)
{
    method += () => set(get() - method);
    set(runAtBeginning ? method + get() : get() + method);
}

RunWithMethodNextTime(() => HandleUpdate, value => HandleUpdate = value, () => Invoke(method, interval), true);