Executing a Code Module Called by TestStand in an STA Thread Primary Software: TestStandPrimary Software Version: 3.0 Primary Software Fixed Version: N/A Secondary Software: N/A
Problem: My code module displays a window containing an ActiveX control. I know that for my module to correctly display the ActiveX control, it must be launched in a thread initialized as STA (single-threaded apartment). In order to accomplish this, I placed the TestStand step calling my module in a subsequence. I then configured a Sequence Call step to call my subsequence in a single-threaded apartment thread. However, when the Sequence Call step creates the new thread and my code module is executed, I experience the same problems, as if my code module was ran in a thread that was not initialized as single-threaded apartment. Why is this and how can I make it work? Solution: By default, TestStand initializes new executions and threads to use the multi-threaded apartment model. Thus, if your step's load option is set to Preload when execution begins (which is the default setting), TestStand will load its code module in the multi-threaded apartment (MTA) thread that is created when the execution starts. Therefore, for a code module to execute in a single-threaded apartment (STA) thread created by a Sequence Call step in TestStand, you need to make sure that it is loaded after the STA thread is created. You can accomplish this by configuring the step calling your code module to load it dynamically:
Related Links: KnowledgeBase 30E9LEEV: New Sequence Adapter COM Multithreading Setting in TestStand 3.0 KnowledgeBase 2JIC15IJ: DLL Works When Called outside of TestStand but Not When Called from TestStand Developer Zone Example: Displaying a Dialog With ActiveX Controls On It From a DLL Called by TestStand Attachments:
Report Date: 05/19/2004 Last Updated: 09/05/2007 Document ID: 39IE8AMT |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
