public static EnumResponse FromResponse(WebcamResponse response)
        {
            var curr = new EnumResponse();

            var packet = response.packet;
            var offset = 0;

            curr.index = BitConverter.ToInt32(packet, offset);
            offset    += 4;

            var nLen = BitConverter.ToInt32(packet, offset);

            offset += 4;

            curr.name = Encoding.Unicode.GetString(packet, offset, nLen);
            offset   += nLen;

            var nDevice = BitConverter.ToInt32(packet, offset);

            offset += 4;

            curr.device = Encoding.Unicode.GetString(packet, offset, nDevice);
            offset     += nDevice;

            return(curr);
        }
        IEnumerator <ITask> WaitForEnumResponses(Port <List <CameraInstance> > resultPort)
        {
            List <CameraInstance> cameras = new List <CameraInstance>();

            for (; ;)
            {
                EnumResponse    response = null;
                HresultResponse done     = null;

                yield return(Arbiter.Choice(
                                 Arbiter.Receive <EnumResponse>(false, _pipeDataPort, success => response = success),
                                 Arbiter.Receive <HresultResponse>(false, _pipeDataPort, hresult => done = hresult)
                                 ));

                if (done != null)
                {
                    if (done.type == WebcamResponse.EnumerateDevices)
                    {
                        break;
                    }
                }
                else
                {
                    var camera = new CameraInstance();

                    camera.DevicePath   = response.device;
                    camera.FriendlyName = response.name;

                    cameras.Add(camera);
                }
            }

            foreach (var camera in cameras)
            {
                var formatPort = EnumFormats(camera);

                yield return(Arbiter.Receive(false, formatPort, success => camera.SupportedFormats = success));
            }

            resultPort.Post(cameras);
        }