From f357b2423cd786774cc9ee1bdeca93b9e1165347 Mon Sep 17 00:00:00 2001 From: Morten Nielsen Date: Fri, 31 Jul 2020 15:23:31 -0700 Subject: [PATCH] improve ntrip streaming --- src/SampleApp.WinDesktop/NtripView.xaml.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/SampleApp.WinDesktop/NtripView.xaml.cs b/src/SampleApp.WinDesktop/NtripView.xaml.cs index 583ab89..33284f3 100644 --- a/src/SampleApp.WinDesktop/NtripView.xaml.cs +++ b/src/SampleApp.WinDesktop/NtripView.xaml.cs @@ -60,13 +60,21 @@ namespace SampleApp.WinDesktop _ = Task.Run(async () => { byte[] buffer = new byte[1024]; + int count = 0; while (true) { - var count = await stream.ReadAsync(buffer); + try + { + count = await stream.ReadAsync(buffer).ConfigureAwait(false); + } + catch (System.Exception ex) + { + Debugger.Break(); + } var device = MainWindow.currentDevice; if (device != null && device.CanWrite) { - await device.WriteAsync(buffer, 0, count); + await device.WriteAsync(buffer, 0, count).ConfigureAwait(false); Dispatcher.Invoke(() => { ntripstatus.Text = $"Transmitted {ntripStream.Position} bytes";