Termination Monitor - .NET
- Updated2025-03-28
- 2 minute(s) read
Purpose
This example demonstrates the use of the Termination Monitor function in .NET. The Termination Monitor allows a code module to stop executing if TestStand attempts to terminate or abort the execution.
Example File
Location
<TestStand Public>\Examples\Fundamentals\Termination Monitor\dotNET\Termination Monitor.seq
Highlighted Features
- .NET Adapter
- Termination Monitor
Major API
None
Prerequisites
None
How to Use This Example
This example uses a .NET Action step to call a function in a .NET assembly that runs indefinitely. Since it uses the Termination Monitor functionality, the function is able to stop when TestStand attempts to terminate or abort execution. If the function did not call the Termination Monitor method, TestStand would be unable to terminate or abort the execution.
To review the functions used in this example, open Termination Monitor Example Form.cs located at <TestStand Public>\Examples\Fundamentals\Termination Monitor\dotNET\Termination Monitor Example\Termination Monitor Example Form.cs.
In the InitializeTerminationStateChecking()method, notice that the Execution.InitTerminationMonitor method from the TestStand API is used to initialize the termination monitor and obtain a reference to data required by other Termination Monitor functions. Every 100 milliseconds, the state of the execution is queried with the Execution.GetTerminationMonitorStatus method from the TestStand API. If TestStand is attempting to terminate or abort the execution, this code module finishes its execution.
Complete the following steps to run the example:
- In TestStand, select Execute»Single Pass to run the sequence.
- When the TerminationMonitorExample dialog appears, the sequence will execute indefinitely.
- On the Debug toolbar in TestStand, click the red Terminate button to terminate the execution. Observe that the execution terminates successfully.