From dd355b493102492ae52845ffe76f4f2c1d8d8090 Mon Sep 17 00:00:00 2001 From: BjAlvestad <40029656+BjAlvestad@users.noreply.github.com> Date: Thu, 6 Jun 2019 11:23:47 +0200 Subject: [PATCH] Adds refrence to issue #4 in GitHub issues tracker --- .../Communication/Simulator/SimulatedLidarPacketReceiver.cs | 2 +- .../Communication/Simulator/SimulatedVehicleCommunication.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SensorVehicle-main/Communication/Simulator/SimulatedLidarPacketReceiver.cs b/SensorVehicle-main/Communication/Simulator/SimulatedLidarPacketReceiver.cs index a4548ef..b547023 100644 --- a/SensorVehicle-main/Communication/Simulator/SimulatedLidarPacketReceiver.cs +++ b/SensorVehicle-main/Communication/Simulator/SimulatedLidarPacketReceiver.cs @@ -31,7 +31,7 @@ private float[] GetDistancesFromSimulator() { ValueSet valuesToSend = new ValueSet {{"LIDAR", ""}}; - ValueSet dataReceived = Task.Run(() => _simulatorCommunication.RequestDataAsync(valuesToSend)).GetAwaiter().GetResult(); //TODO: This is a temporary hack that blocks the async method. WARNING MAY CAUSE ISSUES!. See if Read() can be rewritten to be async. See Figure 7 "The Thread Pool Hack" on https://msdn.microsoft.com/en-us/magazine/mt238404.aspx + ValueSet dataReceived = Task.Run(() => _simulatorCommunication.RequestDataAsync(valuesToSend)).GetAwaiter().GetResult(); //TODO: (ref. issue #4) This is a temporary hack that blocks the async method. WARNING MAY CAUSE ISSUES!. See if Read() can be rewritten to be async. See Figure 7 "The Thread Pool Hack" on https://msdn.microsoft.com/en-us/magazine/mt238404.aspx return dataReceived["DATA"] as float[]; } diff --git a/SensorVehicle-main/Communication/Simulator/SimulatedVehicleCommunication.cs b/SensorVehicle-main/Communication/Simulator/SimulatedVehicleCommunication.cs index ebdb0de..6aaaefc 100644 --- a/SensorVehicle-main/Communication/Simulator/SimulatedVehicleCommunication.cs +++ b/SensorVehicle-main/Communication/Simulator/SimulatedVehicleCommunication.cs @@ -32,7 +32,7 @@ public void Write(MessageCode message, params int[] data) valuesToSend.Add("NUM_OF_INTS", data.Length); valuesToSend.Add("DATA", data); - _simulatorCommunication.SendMessageAsync(valuesToSend); //BUG: Since this async task is not awaited, it will swallow any exception. E.g. a failed write for setting wheel speed will never throw exception in Wheel classes TryCatch block. + _simulatorCommunication.SendMessageAsync(valuesToSend); //BUG: (ref. issue #4) Since this async task is not awaited, it will swallow any exception. E.g. a failed write for setting wheel speed will never throw exception in Wheel classes TryCatch block. } public VehicleDataPacket Read() @@ -41,7 +41,7 @@ public VehicleDataPacket Read() valuesToSend.Add("ADDRESS", (int)_simulatedDevice); valuesToSend.Add("REQUEST", ""); - ValueSet dataReceived = Task.Run(() => _simulatorCommunication.RequestDataAsync(valuesToSend)).GetAwaiter().GetResult(); //TODO: This is a temporary hack that blocks the async method. WARNING MAY CAUSE ISSUES!. See if Read() can be rewritten to be async. See Figure 7 "The Thread Pool Hack" on https://msdn.microsoft.com/en-us/magazine/mt238404.aspx + ValueSet dataReceived = Task.Run(() => _simulatorCommunication.RequestDataAsync(valuesToSend)).GetAwaiter().GetResult(); //TODO: (ref. issue #4) This is a temporary hack that blocks the async method. WARNING MAY CAUSE ISSUES!. See if Read() can be rewritten to be async. See Figure 7 "The Thread Pool Hack" on https://msdn.microsoft.com/en-us/magazine/mt238404.aspx NewDataReceived?.Invoke(this, EventArgs.Empty);