Table of Contents

Method RunOnce

Namespace
Alternet.UI
Assembly
Alternet.UI.Common.dll

RunOnce(ref bool, Action, bool)

Executes the specified action only once, ensuring it is not run again if already executed.

public static void RunOnce(ref bool alreadyExecuted, Action action, bool useTimer = true)

Parameters

alreadyExecuted bool

A reference to a Boolean value indicating whether the action has already been executed. Set to true after the action is run.

action Action

The action to execute if it has not already been executed. Cannot be null.

useTimer bool

true to execute the action asynchronously using a timer; otherwise, false to execute the action immediately.

Remarks

If useTimer is set to true, the action is invoked on the timer's tick event. This can be useful to defer execution until after the current event loop iteration. If useTimer is false, the action is executed immediately. This method is not thread-safe; concurrent calls may result in the action being executed more than once.