Skip to main content
Version: Current

TaskServices.CancelTaskAsync

Description​

Cancel an existing Task with a specified Task ID from the connected AI Command Center.

Signature [C#]​

Task CancelTaskAsync(int taskId);

Properties​

Input​

ParameterTypeRequired / defaultDescription
taskIdintRequiredSpecify the taskId to cancel.

Remarks​

Use CancelTaskAsync API to cancel a Task with a specified task ID from the connected AI Command Center.

Example​

C#
public async Task CancelTask()
{
IControlRoomContext context = LoginControlRoom();
try
{
int taskId = 1;
await context.Tasks.CancelTaskAsync(taskId);
}
finally
{
context.Close();
}
}
Connection helper
public IControlRoomContext LoginControlRoom()
{
string RequiredSetting(string name) => Environment.GetEnvironmentVariable(name) ?? throw new InvalidOperationException($"Set {name} before running this example.");
string serverUrl = RequiredSetting("INTELLIBUDDIES_SERVER_URL");
string userName = RequiredSetting("INTELLIBUDDIES_USERNAME");
string password = RequiredSetting("INTELLIBUDDIES_PASSWORD");
string connectionString = $"ServerUrl={serverUrl};UserName={userName};Password={password}";
IControlRoomContext context = new ControlRoomContext(connectionString);
context.Open();
return context;
}

See Get started for namespaces, configuration, and context cleanup, and SDK usage for error handling.