NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling a step to show a non-modal WPF window

Solved!
Go to solution

Does anyone have an example of calling a non-modal WPF window.  I'm able to successfully call a modal window but hangs TestStand UI until the window is closed.

 

I've seen the out-of-box example (below) that does what I need but need to use WPF not WinForms.

 

C:\Users\Public\Documents\National Instruments\TestStand 2019 (32-bit)\Examples\Demos\Computer Motherboard Test\DotNET

 

Any help is appreciated.  Thx

0 Kudos
Message 1 of 7
(298 Views)
Solution
Accepted by topic author testergi

Greg,

1) Although I hit this in the past with ActiveX based UIs in a DLL, so may be an issue for WPF but easy to test. All TestStand execution threads are initialized as MTA (multi-thread apartment) and at least for older UI frameworks, STA (single-) threads were required. You can easily test this by moving your step that displays your dialog into a separate sequence, and then call the sequence using a Sequence Call step with Execution Options set to 'Use New Thread', and its Advanced Settings configured with 'Use Single-Threaded Apartment' enabled.

 

2) Also take a look at this older forum post that has some code snippets: Re: Calling WPF from TestStand

Scott Richardson
https://testeract.com
0 Kudos
Message 2 of 7
(260 Views)

Thanks @Scott_Richardson for response.  I will review your approach.

 

I did come across the link before and I have something setup similar to its code snippet.  However, this is around modal (ShowDialog) where it locks up TestStand until I click a button in my window to close.  Need to be able to still click stuff in TestStand (like viewing reports and such) along with minimizing TS to interact with other Windows things (desktop, etc.).

 

Thanks again.

0 Kudos
Message 3 of 7
(256 Views)

Greg -

Got it, the modality is owned by the WPF code so how you are displaying the panel needs to be understood and likely changed, which is not my domain. There are ways to make a window top-most, so not sure if you want to look at that as well.

 

If you want TestStand to be able to pause an execution while the window is open and auto close if the execution is terminated or complete, there are ways of doing this, see non-WPF examples here: 

 

 

Scott Richardson
https://testeract.com
0 Kudos
Message 4 of 7
(242 Views)

Hi Scott,

 

I had some time to try out your suggestion, about a separate sequence thread with STA set, and does appear to work.  It is not ideal as it would be nice to just have a step that calls the Show (or similar) method without the extra supporting logic.  The disadvantage is being required to do this for any/every time of WPF window needed to display.

 

I'm going to keep this thread open (pun intended 🤣) in case there are some others that see and want to chime in.

 

Thanks again on help and, at least, a working option.  👍

0 Kudos
Message 5 of 7
(237 Views)
Solution
Accepted by topic author testergi

Finally figured it out.  Need to remove the TestStand engine modal logic, but still call ShowDialog() method on the window control so it will halt on the step until closed and also allow to continue interacting with main TestStand UI.

 

testergi_0-1725540019722.png

 

Message 6 of 7
(208 Views)

Simple solution, thanks for posting.

Scott Richardson
https://testeract.com
0 Kudos
Message 7 of 7
(194 Views)