How to open SCPI Instruments in parallel

We are in need of a Custom Test Step which reads all SCPI Instruments (with different VISA Address), where we need to access SCPI Instruments parallely (Open and send a SCPI command).
However the open() method opens up the SCPI instrument one after the other. Is there a way I can open instruments (with different VISA Address) parallely.
For example I tried opening intruments as follows in different tasks assuming there are 3 instruments
var instruments = InstrumentSettings.Current;
if (instruments != null && instruments.Count > 0)
{

                var inst1 = instruments[0] as ScpiInstrument;
                Task.Run(() => 
                {
                    try
                    {
                        MessageBox.Show("1");
                        inst1.Open();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        Log.Error(ex.Message);
                    }
                    
                });

                var inst2 = instruments[1] as ScpiInstrument;
                Task.Run(() =>
                {
                    try
                    {
                        MessageBox.Show("2");
                        inst2.Open();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        Log.Error(ex.Message);
                    }

                });

                var inst3 = instruments[2] as ScpiInstrument;
                Task.Run(() =>
                {
                    try
                    {
                        MessageBox.Show("3");
                        inst3.Open();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        Log.Error(ex.Message);
                    }

                });
2 Likes

@bhushan.matade generally, we recommend letting OpenTAP handle opening and closing instrument connections and leaving them open throughout the whole test. This is done automatically in parallel already, but VISA shares a single resource manager, so we are limited there. You can thought use the Parallel Test Step to start test steps in their own threads. Would something like that work for your use case?

In addition, you can reference how OpenTAP handles resource open: