Skip to content

Method ExecuteAsync

Namespace: Belay.Core
Assembly: Belay.Core.dll

ExecuteAsync(string, CancellationToken)

Executes Python code on the device using sophisticated adaptive Raw REPL protocol. Includes comprehensive input validation and security checks to prevent code injection.

csharp
public Task<string> ExecuteAsync(string code, CancellationToken cancellationToken = default)

Parameters

code string

The Python code to execute.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<string>

The execution result.

Exceptions

ArgumentNullException

Thrown when code is null.

ArgumentException

Thrown when code fails security validation.

DeviceException

Thrown when device execution fails.

ExecuteAsync<T>(string, CancellationToken)

Executes code and returns typed result (simplified generic version).

csharp
public Task<T> ExecuteAsync<T>(string code, CancellationToken cancellationToken = default)

Parameters

code string

The Python code to execute.

cancellationToken CancellationToken

Cancellation token for the operation.

Returns

Task<T>

The execution result converted to the specified type.

Type Parameters

T

The type to convert the result to.

Released under the Apache License 2.0.