Example Code

TestStand Notification Cross-Process Example in C#

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • Teststand

Code and Documents

Attachment

Description

This example demonstrates the ability for the TestStand engine to communicate through the Sync Manager with another instance of the TestStand engine. The first instance is created by a stand-alone application developed in C#. The second instance of the engine is used by TestStand to run a test sequence.

 
The stand-alone application, a Windows forms application created in Microsoft Visual Studio with C#, uses the TestStand Engine and the Sync Manager class to create a TestStand Notifier. In the C# application, the notifier is created when the user begins the application. The notifier is named, "*MyNotification" in both TestStand and the C# application. When a synchronization object name begins with an asterisk, such as *MyNotification", multiple processes can share the reference to the object. 

In the C# application, the TestStand API is used to notify any process that is waiting on this specific notifier that an event has occurred, otherwise known as setting the notifier. This is executed when the user selects the Start button, and the Station Status displays "Ready..." on the C# application's user interface. When the user selects, Stop, the application will clear out the notifier, but the notifier will still exist.

 

Simultaneously, a separate TestStand execution waits on this notifier to be set by the user interface and informs the user when it has been set. The TestStand execution will terminate if the notifier object does not exist. Otherwise, when it has been set by the stand-alone application, the user will see a message pop-up indicating that the notifier has been set. 

 

Note: This example is applicable to situations where the test station is configured in a separate application or process from TestStand, and then informs TestStand when all test stations are ready.

How to Use

  1. Open the solution, "TestStandNotifierExample.sln" in Microsoft Visual Studio and run the application.
  2. Open the TestStand sequence, "TestStandNotificationExample.seq" and execute the sequence, with either Single Pass or Test UUT. The sequence file will wait for the notifier to be set by the C# application.
  3. Click Start on the Windows form created by the C# application. The Station Status will display "Starting..." until the progress bar has filled. Once it has filled, the Station Status will display "Ready..." and the notifier will be set.
  4. The TestStand sequence will display a message pop-up notifying the user that the Notifier has been set, and the execution will then terminate.
  5. The user can clear out the notifier by selecting Stop on the Windows form. The Station Status will display "Stopping..." and the value of the progress bar will begin to decrease to zero. Once the progress bar has emptied out, the Station Status will display "Station Idle..." and the notifier will be cleared of its set state.

Related Links

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.