# IOException - SetFeature failed

**URL:** <https://forums.blinkstick.com/t/ioexception-setfeature-failed/141>\
**Category:** Support\
**Created:** [March 6, 2015, 11:36pm UTC](https://forums.blinkstick.com/t/ioexception-setfeature-failed/141 "2015-03-06T23:36:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![themeq](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/themeq/32/70_2.png) [@themeq](https://forums.blinkstick.com/u/themeq)\
**Post date:** [March 6, 2015, 11:36pm UTC](https://forums.blinkstick.com/t/ioexception-setfeature-failed/141/1 "2015-03-06T23:36:48Z")

</div>

Hi, what does this error mean? Here is my code:

```auto
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim BMP As New Drawing.Bitmap(1, 1)
        Dim GFX As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(BMP)
        GFX.CopyFromScreen(New Drawing.Point(MousePosition.X, MousePosition.Y), New Drawing.Point(0, 0), BMP.Size)
        Dim Pixel As Drawing.Color = BMP.GetPixel(0, 0)
        Dim device2 = BlinkStick.FindAll
        For Each device In device2
            device.SetMode(2)
            device.OpenDevice()
            For k = 0 To 7
                Dim j As Byte = k
                device.SetColor(0, j, RgbColor.FromRgb(Pixel.R, Pixel.G, Pixel.B))
            Next
        Next

    End Sub
```

Thanks

---

<div class="post-metadata">

**Author:** ![arvydas](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/arvydas/32/242_2.png) [@arvydas](https://forums.blinkstick.com/u/arvydas)\
**Post date:** [March 6, 2015, 11:54pm UTC](https://forums.blinkstick.com/t/ioexception-setfeature-failed/141/2 "2015-03-06T23:54:38Z")

</div>

You are sending the colors too fast. Add a delay of about 20ms after each SetColor function call.

Also, the correct way is to open the device first and then set the mode:

```auto
device.OpenDevice()
device.SetMode(2)

```

---

<div class="post-metadata">

**Author:** ![jtitley](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/j/c89c15/32.png) [@jtitley](https://forums.blinkstick.com/u/jtitley)\
**Post date:** [May 11, 2017, 4:06am UTC](https://forums.blinkstick.com/t/ioexception-setfeature-failed/141/3 "2017-05-11T04:06:13Z")

</div>

I’m getting the same issue. I’ve put in the delay of 20ms but after some time the blink stick just crashes with this error.

I understand this might happen when debugging and stopping the program abnormally but in my case it is running outside debugger.

I’d like to use this in a production setting but I’m finding the stability a concern.

---

<div class="post-metadata">

**Author:** ![arvydas](https://forums.blinkstick.com/user_avatar/forums.blinkstick.com/arvydas/32/242_2.png) [@arvydas](https://forums.blinkstick.com/u/arvydas)\
**Post date:** [May 11, 2017, 5:49am UTC](https://forums.blinkstick.com/t/ioexception-setfeature-failed/141/4 "2017-05-11T05:49:03Z")

</div>

Can you post your code sample for a quick review?

---

<div class="post-metadata">

**Author:** ![jtitley](https://forums.blinkstick.com/letter_avatar_proxy/v4/letter/j/c89c15/32.png) [@jtitley](https://forums.blinkstick.com/u/jtitley)\
**Post date:** [May 11, 2017, 9:22am UTC](https://forums.blinkstick.com/t/ioexception-setfeature-failed/141/5 "2017-05-11T09:22:57Z")

</div>

Cool thanks. A second pair of eyes is helpful. Really want to go live with this 😄

Here is where I’m getting crashes.

```
    private void Caution(bool firstTime)
    {
        using (new BlinkStickMutex(2000))
        {
            if (!firstTime)
            {
                if (WaitorQuit(20))
                {
                    return;
                }
                _device.Pulse("darkorange");
                if (WaitorQuit(20))
                {
                    return;
                }
                _device.Morph("darkorange");
                return;
            }

            if (WaitorQuit(20))
            {
                return;
            }

            _device.Morph("darkorange");

            if (WaitorQuit(20))
            {
                return;
            }

            for (int i = 0; i < Properties.Settings.Default.BlinkLoop; i++)
            {
                _device.Pulse("darkorange");
                if (WaitorQuit(20))
                {
                    return;
                }
            }

            _device.Morph("darkorange");

            WaitorQuit(20);                
        }
    }
```
