NetworkSuite.EnterCriticalSection Method

Applies to TestComplete 15.69, last modified on November 13, 2024
The Network Suite functionality is deprecated. We don’t recommend using it for distributed testing. Consider using a CI/CD system for managing distributed tests. See Migrating Distributed Tests to CI/CD Systems for details. In case you need to run web tests on multiple environments in parallel, you can also try using your project’s Execution Plan.

Description

The EnterCriticalSection method requests access to a critical section until the current project obtains access or the specified time limit is reached.

Declaration

NetworkSuite.EnterCriticalSection(Name, Timeout)

Name [in]    Required    String    
Timeout [in]    Optional    Integer Default value: 0   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Name

Specifies the name of the needed critical section (case-insensitive).

Timeout

Sets the time limit in milliseconds. 0 (the default value) means indefinite time limit.

Note that some factors (like the network bandwidth or machine workload) can affect the work of the method, that is, you should not specify short timeout, because your tests may fail.

Result Value

True if the current project obtains access to the desired critical section, and False otherwise.

Remarks

To leave a critical section, use the NetworkSuite.LeaveCriticalSection method.

Example

The following script halts the network suite's execution if the script doesn't get access to the CS1 critical section within the specified period.

JavaScript, JScript

if (NetworkSuite.EnterCriticalSection("CS1", 600000))
{
  ...
  NetworkSuite.LeaveCriticalSection("CS1");
}
else
  NetworkSuite.Stop();

Python

if NetworkSuite.EnterCriticalSection("CS1", 600000):
  NetworkSuite.LeaveCriticalSection("CS1")
else: 
  NetworkSuite.Stop()

VBScript

If NetworkSuite.EnterCriticalSection("CS1", 600000) = True Then
  ...
  NetworkSuite.LeaveCriticalSection "CS1"
Else
  NetworkSuite.Stop
End If

DelphiScript

if NetworkSuite.EnterCriticalSection('CS1', 600000) then
begin
  ...
  NetworkSuite.LeaveCriticalSection('CS1');
end
else
  NetworkSuite.Stop;

C++Script, C#Script

if (NetworkSuite["EnterCriticalSection"]("CS1", 600000))
{
  ...
  NetworkSuite["LeaveCriticalSection"]("CS1");
}
else
  NetworkSuite["Stop"]();

See Also

Distributed Testing
NetworkSuite.LeaveCriticalSection
Critical Sections

Highlight search results