Beispiel #1
0
        private async void StartReadingData()
        {
            while (true) // todo: build in cancellation support
            {
                try
                {
                    var bytesInQueue = device.GetQueueStatus();
                    bytesInQueue = Math.Max(bytesInQueue, 1); // to make sure we don't create a cpu eating loop

                    var buffer    = new byte[bytesInQueue];
                    var bytesRead = await device.ReadAsync(buffer, bytesInQueue);

                    ReadBuffer = ReadBuffer.Concat(bytesRead).ToArray();
                }
                catch (Exception ex)
                {
                    WriteToLog(string.Format("Exception occurred: {0}", ex.Message));
                }
            }
        }