Skip to content

Plugin.BeginInvokeOnMainThread

method · Plugin · cAlgo.API

DesktopCLICloud

Invokes asynchronously the specified code on the main Plugin thread.

Environment behaviour

CLI — not supported. Plugins cannot run in the CLI: ctrader-cli runs cBots only.

Cloud — not supported. Plugins cannot run in the cloud: it runs cBots only.

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 Plugin thread

Examples

Task.Run(() =>
{
    var response = Http.Get("https://ctrader.com/");
    BeginInvokeOnMainThread(() => Print("Status code: {0}", response.StatusCode));
});
api.BeginInvokeOnMainThread(lambda: api.Print("Running on the plugin main thread"))