Thread Concurrency Models

TestStand 2019 Help

Edition Date: May 2019

Part Number: 370052AA-01

»View Product Info
Download Help (Windows Only)

In ActiveX, you can initialize a thread to use the single threaded apartment (STA) concurrency model or the multithreaded apartment (MTA) concurrency model. Before you use a thread with ActiveX, you must initialize the thread to one of these models. Typically, the software development environment you are using initializes the threads in the application for you.

When using the TestStand API to implement a user interface or other application program, you can use threads of either concurrency model.

When using ActiveX automation from within a code module, you do not have to initialize the thread concurrency model because the initial thread in an execution is initialized as multithreaded and TestStand initializes new threads in an execution depending on the option you select in the Sequence Call Advanced Settings window.

When using ActiveX controls on a window or dialog box a code module creates, you must ensure that the thread is initialized as STA. If TestStand preloads a code module when an execution starts, the root execution, which is initialized as MTA, typically loads the code module. When a code module is loaded dynamically, the thread that first executes the step loads the code module.

You must complete the following steps to ensure that a code module is loaded by an STA thread.

  • Execute the step in an STA thread. Use a Sequence Call step to create a STA thread by enabling the Use Single-Threaded Apartment option for the step in the Thread Settings dialog box.
  • Select Load Dynamically for the Load Option option in the Step Properties dialog box.

For LabVIEW VIs that contain ActiveX controls, set the Preferred Execution System option for the VI to user interface to ensure that the VI executes within the user interface thread, which is typically an STA thread.

Note Note  When you call a LabVIEW VI that creates ActiveX references, such as calling the ApplicationMgr.GetEngine method directly, you configure the VI to use the same as caller execution system, and you call the VI from a sequence running in a single-threaded apartment thread, LabVIEW might seem to hang with 100% processor use. Change the Preferred Execution System option in LabVIEW to a value different from same as caller to work around this issue.

See Also

MFC ActiveX Container Dialog Boxes (Example)

WAS THIS ARTICLE HELPFUL?

Not Helpful