From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Calling WPF from TestStand

Hello, I'm not a TestStand programmer so I don't know how NotifyStartOfModalDialogEx works, but I'm quite sure your WPF should be linked to the parent (that should be TestStand) to have a chance to be modal (like in the code from codeproject).

I would also modify the code this way:

 

public static void ShowSerialDialogWPF(SequenceContext seqContext, out string serialNumber, out bool continueTesting)
{

...

using(SerialDialog userInterfaceDialog = new SerialDialog())

{

System.Threading.Thread uiThread = new System.Threading.Thread(() =>
{
    userInterfaceDialog.ShowDialog();
});
uiThread.SetApartmentState(System.Threading.ApartmentState.STA);
uiThread.Start();
uiThread.Join();

 

serialNumber = userInterfaceDialog.Serial;

continueTesting = userInterfaceDialog.ContinueTesting;
}

...

}

 

HAGD

0 Kudos
Message 11 of 14
(579 Views)

I will try it.

 

Just a Quick question. Why are you using the using() statement?

 

Juan Navarro
0 Kudos
Message 12 of 14
(565 Views)

Hi, because I guess the window object is IDisposable, and so will be disposed anyway.

0 Kudos
Message 13 of 14
(561 Views)

It seems like the STA problem asked in the beginning returned. Cant figure out how to make the WPF STA without calling another thread which I assume is the problem to follow the windows forms format.

 

Also I cannot find a WPF dialog example for Teststand, only Forms.

 

Juan Navarro
0 Kudos
Message 14 of 14
(536 Views)