sdk
latest
false
- Overview
- Custom activities
- Migrating Activities to .NET 6
- Release Notes
- Building Workflow Analyzer Rules
- Building Activities Project Settings
- Creating Custom Wizards
- Prioritize Activities by Scope
- UiPath.Activities.Api.Base
- UiPath.Studio.Activities.Api
- UiPath.Studio.Activities.Api.Activities
- UiPath.Studio.Activities.Api.BusyService
- UiPath.Studio.Activities.Api.ExpressionEditor
- UiPath.Studio.Activities.Api.Expressions
- UiPath.Studio.Activities.Api.Licensing
- UiPath.Studio.Activities.Api.Mocking
- UiPath.Studio.Activities.Api.ObjectLibrary
- UiPath.Studio.Activities.Api.PackageBindings
- UiPath.Studio.Activities.Api.ProjectProperties
- UiPath.Studio.Activities.Api.ScopedActivities
- UiPath.Studio.Activities.Api.Settings
- UiPath.Studio.Activities.Api.Wizards
- UiPath.Studio.Activities.Api.Workflow
- UiPath.Studio.Api.Controls
- UiPath.Studio.Api.Telemetry
- UiPath.Studio.Api.Theme
- Robot JavaScript SDK
- Triggers SDK
Developer Guide
Last updated Oct 25, 2024
Timeout
The Timeout toggle adds a Timeout property to the activity. If the activity does not finish executing within the amount of time specified in this property, an error will be thrown. The default timeout is automatically set to 60000 ms (1 minute).
Activity Creator
Generated Code
Activities with timeouts contain an
ExecuteWithTimeout
method, which contains the execution logic of that activity. This method is called within the main ExecuteAsync
method and times out after a set amount of time (60 seconds by default).
protected override async Task<Action<AsyncCodeActivityContext>> ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
{
// Inputs
var timeout = TimeoutMS.Get(context);
// Set a timeout on the execution
var task = ExecuteWithTimeout(context, cancellationToken);
if (await Task.WhenAny(task, Task.Delay(timeout, cancellationToken)) != task) throw new TimeoutException(Resources.Timeout_Error);
// Outputs
return (ctx) => { };
}
private async Task ExecuteWithTimeout(AsyncCodeActivityContext context, CancellationToken cancellationToken = default)
{
///////////////////////////
// Add execution logic HERE
///////////////////////////
}
protected override async Task<Action<AsyncCodeActivityContext>> ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
{
// Inputs
var timeout = TimeoutMS.Get(context);
// Set a timeout on the execution
var task = ExecuteWithTimeout(context, cancellationToken);
if (await Task.WhenAny(task, Task.Delay(timeout, cancellationToken)) != task) throw new TimeoutException(Resources.Timeout_Error);
// Outputs
return (ctx) => { };
}
private async Task ExecuteWithTimeout(AsyncCodeActivityContext context, CancellationToken cancellationToken = default)
{
///////////////////////////
// Add execution logic HERE
///////////////////////////
}
Effect in UiPath Studio