Stop Method

Applies to TestComplete 14.40, last modified on April 22, 2021

Description

The Stop method unconditionally stops execution of the given task.

Declaration

TaskObj.Stop()

TaskObj An expression, variable or parameter that specifies a reference to a Task object
Result None

Applies To

The method is applied to the following object:

Result Value

None.

Remarks

You cannot stop the task execution from the OnNetJobStateChange, OnNetSuiteStateChange and OnNetTaskStateChange event handlers.

Example

The following script halts the task’s execution if it does not stop on its own for a specified period.

JavaScript, JScript

function Test()
{
  var Task = NetworkSuite.Jobs.ItemByName("Job1").Tasks.ItemByName("Task1");
  …
  if (! Task.WaitForState(ns_Idle, 600000))
    Task.Stop();
}

Python

def Test():
  Task = NetworkSuite.Jobs.ItemByName["Job1"].Tasks.ItemByName["Task1"]
  if not Task.WaitForState(ns_Idle, 600000):
    Task.Stop()

VBScript

Sub Test
  Set Task = NetworkSuite.Jobs.ItemByName("Job1").Tasks.ItemByName("Task1")
  …
  If Not Task.WaitForState(ns_Idle, 600000) Then
    Task.Stop
  End If
End Sub

DelphiScript

procedure Test;
var Task;
begin
  Task := NetworkSuite.Jobs.ItemByName['Job1'].Tasks.ItemByName['Task1'];
  …
  if not Task.WaitForState(ns_Idle, 600000) then
    Task.Stop;
end;

C++Script, C#Script

function Test()
{
  var Task = NetworkSuite["Jobs"]["ItemByName"]("Job1")["Tasks"]["ItemByName"]("Task1");
  …
  if (! Task["WaitForState"](ns_Idle, 600000))
    Task["Stop"]();
}

See Also

Distributed Testing
Task.Run
Task.State
Task.WaitForState

Highlight search results