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: 

Thread execution number?

Hi - All my test steps use the .Net step types. Is there a way to pass back to (or read from) my C# code the current TestStand thread number that has called my C# code?

 

When my C# code creates its own log files, it would be helpful to append the TestStand thread number that has generated the C# log file entry to aid sorting and following test execution in a multi-threaded TS sequence.

 

The current C# log file works well in a single threaded TS sequence but as soon as you add more threads then obviously the C# log file entries are not in an easy to read execution order since they are generated by the multiple threads running.

 

Thanks in advance,

 

Chris

 

thanks in advance

0 Kudos
Message 1 of 4
(1,020 Views)

Hello Chris,

 

You have two methods of doing this:

1. Pass the Sequence Context Reference to your test steps. In your teststep you can use the reference to extract the Thread Reference and later the UniqueThreaID.

 

2. You can pass directly the ThreadID to your TestStep by passing the RunState.Thread.UniqueThreadId as input to your teststep.

 

Hope it helps,

Just a TSUser

 

0 Kudos
Message 2 of 4
(979 Views)

Many thanks for your suggestion.

 

Regards

 

Chris

0 Kudos
Message 3 of 4
(967 Views)

You are welcome!

If you have validated the solution, please don't forget to mark as solution to this forum thread so that it can be considered as closed !

 

Cheers,

Just a TSUser

0 Kudos
Message 4 of 4
(961 Views)