From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Some UIMessages not received while C# GUI is open

I have a sequence file that has a front end GUI written in C#. When the MainSequence is run, there is a sequence call step to show the C# GUI using a new thread. The GUI is used to select which other sequences to run in the sequence file as well as display percent complete status, etc.

 

The GUI form registers the ApplicationMgr.UIMessageEvent handler to respond to updates from sequence execution. I passed a reference of the ApplicationMgr using RunState.Engine.GetInternalOption(InternalOption_ApplicationManager) to the form.

 

If an error occurs in the sequence, the error dialog box does not display until after I close the form. It seems like for whatever reason, the form doesn't receive UIMessages (ie. UIMessageCodes.UIMsg_BreakOnRunTimeError) from the Engine itself (however it does work for custom UIMessages, ex the GUI updates when the sequence is execute properly).

 

I guess I don't have a full understanding of how UIMessages work and how it works with another thread.

0 Kudos
Message 1 of 4
(3,728 Views)

Are you perhaps canceling the further processing of UImessages other than your custom ones, thus keeping the main (original) UI from handling them?

 

What UIMessages does your new thread UI need to handle? Why are you launching a UI in a new thread rather than just communicating with the main/original UI and having it display a panel to the user? That would be simpler.

 

It might be helpful if you could describe in more detail what you are trying to do and what your code currently does.

 

-Doug

0 Kudos
Message 2 of 4
(3,707 Views)

I don't think I am cancelling the further processing of UIMessages (I am specifically looking for UIMessageCodes.UIMsg_BreakOnRunTimeError as well as my custom ones). The main UI (in this case TestStand itself) does eventually get to handle it when I close the GUI form.

I basically made a custom operator interface (but not a stand alone .exe operator interface like in the TS example folder) to allow the user to pick and choose which sequences they would like to run from the sequence file.

The custom operator interface is a C# form and is compiled into a DLL which is then executed by a .NET adapter step which executes the ShowDialog() method.

 


The sequence file is structured as follows:

[MainSequence]
[GUI]
[Test1]
[Test2]
[Test3]
...
[TestN]


The MainSequence has the following steps:

- Create notifier for GUI
- Run [GUI] in a new thread
- Init UUT / Query UUT status
- Wait for notifier from GUI to execute selected sequences
- Execute sequences that was chosen by the GUI

 

 

 

Let me know if there's any more detail I need to provide.

 

-Mike

0 Kudos
Message 3 of 4
(3,700 Views)

I think there are some known issues with using a ActiveX control events across threads like this. I don't think there is a way to make that work.

 

I recommend one of the following alternatives.

 

1) Make a custom UI instead of a popup UI run from a sequence.

or

2) Using TestStand queues for communication rather than UIMessages. TestStand queues can be used both with a Step type and directly via a COM API (documented in the API help file).

 


Hope this helps,

-Doug

0 Kudos
Message 4 of 4
(3,663 Views)