# How to open SCPI Instruments in parallel

**URL:** <https://forum.opentap.io/t/how-to-open-scpi-instruments-in-parallel/278>\
**Category:** Technical\
**Created:** [March 22, 2021, 8:45am UTC](https://forum.opentap.io/t/how-to-open-scpi-instruments-in-parallel/278 "2021-03-22T08:45:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhushan.matade](https://avatars.discourse-cdn.com/v4/letter/b/91b2a8/32.png) [@bhushan.matade](https://forum.opentap.io/u/bhushan.matade)\
**Post date:** [March 22, 2021, 8:45am UTC](https://forum.opentap.io/t/how-to-open-scpi-instruments-in-parallel/278/1 "2021-03-22T08:45:25Z")

</div>

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);
                    }

                });
```

---

<div class="post-metadata">

**Author:** ![brennen\_direnzo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/brennen_direnzo/32/6_2.png) [@brennen\_direnzo](https://forum.opentap.io/u/brennen_direnzo)\
**Post date:** [March 23, 2021, 11:33pm UTC](https://forum.opentap.io/t/how-to-open-scpi-instruments-in-parallel/278/2 "2021-03-23T23:33:35Z")

</div>

@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:

> <https://gitlab.com/OpenTAP/opentap/-/blob/master/Engine/ResourceTaskManager.cs#L233>
