Emlid.WindowsIot.Hardware.Boards.Navio.NavioRCInputDevice.Receiver C# (CSharp) Method

Receiver() private method

Waits for decoded frames, updates the Channels property and fires the ChannelsChanged event on a separate thread.
private Receiver ( ) : void
return void
        private void Receiver()
        {
            // Run until stopped...
            while (!_stop.IsCancellationRequested)
            {
                // Wait for frame
                PwmFrame frame;
                if (!_frameBuffer.TryDequeue(out frame))
                {
                    _frameTrigger.WaitOne(1000);
                    continue;
                }

                // Validate
                var channelCount = frame.Channels.Length;
                if (channelCount > _channels.Length)
                {
                    // Too many channels
                    Debug.WriteLine(Resources.Strings.NavioRCInputDecoderChannelOverflow, channelCount, _channels.Length);
                    continue;
                }

                // Copy new channel data
                Array.Copy(frame.Channels, _channels, channelCount);

                // Fire event
                ChannelsChanged?.Invoke(this, frame);
            }
        }