Skip to content

Algo.BeginInvokeOnMainThread

method · Algo · cAlgo.API.Internals

DesktopCLICloud

Invokes asynchronously the specified code on the main cBot or Indicator thread.

Definition

public void BeginInvokeOnMainThread(Action action)
api.BeginInvokeOnMainThread(action: Action) -> None

Parameters

Name C# type Python type Description
action Action Action The code to invoke on the main cBot/Indicator thread

Examples

Task.Run(() =>
{
    var result = Math.Sqrt(2);
    BeginInvokeOnMainThread(() => Print("Calculated on a background thread: {0}", result));
});
api.BeginInvokeOnMainThread(lambda: api.Print(f"Running on the main thread at {api.Server.Time}"))