SDK
latest
false
Banner background image
Developer Guide
Last updated Mar 23, 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



Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.