NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Add StationGlobal, FileGlobal and Locals from a C# code module

Is it possible to create StationGlobal, FileGlobal and Locals from a C# code module?

I know it is possible to get and set variables using PropertyObject, but as far as I know it is not possible to create them.

 

Best regards

0 Kudos
Message 1 of 3
(3,151 Views)

The easiest way is to use the PropOption_InsertIfMissing option with the SetVal* methods.

 

Be careful if you have multiple threads accessing the variables at the same time though because if you are creating and deleting variables dynamically while accessing/creating/deleting them from other threads it can lead to race conditions (i.e. crashes and memory corruption). If you need to access the variables from multiple threads at once, I'd recommend creating all the variables upfront, if possible, in the first thread, before any other threads try to access them, otherwise you will need to use a Lock step or step setting to protect access to the variables and any parents variables of variables you are inserting or deleting.

 

Hope this helps,

-Doug

0 Kudos
Message 2 of 3
(3,139 Views)
Thanks a lot, this was exactly what I need.
0 Kudos
Message 3 of 3
(3,090 Views)