Plugin.Sleep
method · Plugin · cAlgo.API
DesktopCLICloud
Suspends the plugin until the specified timespan elapses.
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.
Overloads
| Signature | Description |
|---|---|
Sleep(TimeSpan timespan) | Suspends the plugin until the specified timespan elapses. |
Sleep(int milliseconds) | Suspends the plugin until the specified number of milliseconds elapses. |
Sleep(DateTime dateTime) | Suspends the plugin until the specified datetime. |
Sleep(TimeSpan timespan)
Suspends the plugin until the specified timespan elapses.
public void Sleep(TimeSpan timespan)
api.Sleep(timespan: TimeSpan) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
timespan | TimeSpan | TimeSpan | The Timespan during which the plugin should not react to any events. |
Examples
Print("Waiting 2 seconds");
Sleep(TimeSpan.FromSeconds(2));
RefreshData();
Print("Resumed at {0}", Server.Time);
from System import TimeSpan
api.Print("Waiting 2 seconds")
api.Sleep(TimeSpan.FromSeconds(2))
api.RefreshData()
api.Print(f"Resumed at {api.Server.Time}")
Sleep(int milliseconds)
Suspends the plugin until the specified number of milliseconds elapses.
public void Sleep(int milliseconds)
api.Sleep(milliseconds: int) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
milliseconds | int | int | The number of milliseconds for which the plugin should be suspended. |
Examples
Sleep(500);
RefreshData();
Print("Resumed after 500 ms at {0}", Server.Time);
api.Sleep(500)
api.RefreshData()
api.Print(f"Resumed after 500 ms at {api.Server.Time}")
Sleep(DateTime dateTime)
Suspends the plugin until the specified datetime.
public void Sleep(DateTime dateTime)
api.Sleep(dateTime: DateTime) -> None
Parameters
| Name | C# type | Python type | Description |
|---|---|---|---|
dateTime | DateTime | DateTime | The DateTime until the plugin should be suspended. |
Examples
var resumeTime = Server.Time.AddSeconds(5);
Sleep(resumeTime);
RefreshData();
Print("Resumed at {0}", Server.Time);
resumeTime = api.Server.Time.AddSeconds(5)
api.Sleep(resumeTime)
api.RefreshData()
api.Print(f"Resumed at {api.Server.Time}")