Parallel For Loops (TSM)
- Updated2025-07-31
- 1 minute(s) read
When you obtain multiple sessions, you will usually use a parallel For Loop to control the instruments in parallel to increase multisite efficiency. You do not need to use a parallel For Loop for NI-Digital Pattern, NI-SCOPE, or NI-DCPower pin queries if all instruments or channels belong to the same group in the pin map file. By default, TSM groups all NI-Digital Pattern instruments into the same NI-Digital Pattern instrument group, all NI-SCOPE instruments into the same NI-SCOPE instrument group, and all NI-DCPower channels into the same NI-DCPower channel group. You can edit instrument or channel groups in the Pin Map Editor.
| LabVIEW |
Right-click a For Loop and select Configure Iteration Parallelism from the context menu to create a parallel For Loop. Index the session and channel list arrays in the For Loop to access each instrument in parallel. |
| .NET (C#) | One option for parallel For Loops in .NET is the
System.Threading.Tasks.Parallel.For method. The following example
demonstrates how to use this method to perform a measurement with each instrument
session in parallel.
public static void ExampleCodeModule(ISemiconductorModuleContext semiconductorModuleContext, string dcPowerPins)
{
NIDCPower[] dcPowerSessions;
string[] dcPowerChannelStrings;
semiconductorModuleContext.GetNIDCPowerSessions(dcPowerPins, out dcPowerSessions, out dcPowerChannelStrings);
var measurements = new double[dcPowerSessions.Length];
Parallel.For(0, dcPowerSessions.Length, i =>
{
measurements[i] = PerformMeasurement(dcPowerSessions[i], dcPowerChannelStrings[i]);
});
} |