From ad7379b786656dcd9c4f33d308d9fa75a3b353e0 Mon Sep 17 00:00:00 2001 From: michielpost Date: Mon, 19 Apr 2021 16:31:18 +0200 Subject: [PATCH] Only use blocking collection in SendCommandRawAsync --- src/Q42.HueApi/HueClient-Lights.cs | 7 +++++-- src/Q42.HueApi/Models/Groups/DefaultHueResult.cs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Q42.HueApi/HueClient-Lights.cs b/src/Q42.HueApi/HueClient-Lights.cs index c734e4a..a323b0c 100644 --- a/src/Q42.HueApi/HueClient-Lights.cs +++ b/src/Q42.HueApi/HueClient-Lights.cs @@ -11,6 +11,7 @@ using System.Dynamic; using Q42.HueApi.Models; using Q42.HueApi.Interfaces; +using System.Collections.Concurrent; namespace Q42.HueApi { @@ -183,7 +184,7 @@ public async Task SendCommandRawAsync(string command, IEnumerable results = new BlockingCollection(); HttpClient client = await GetHttpClient().ConfigureAwait(false); await lightList.ForEachAsync(_parallelRequests, async (lightId) => @@ -213,7 +214,9 @@ await lightList.ForEachAsync(_parallelRequests, async (lightId) => }).ConfigureAwait(false); - return results; + HueResults hueResults = new HueResults(); + hueResults.AddRange(results); + return hueResults; } } diff --git a/src/Q42.HueApi/Models/Groups/DefaultHueResult.cs b/src/Q42.HueApi/Models/Groups/DefaultHueResult.cs index e61bc70..fe2211a 100644 --- a/src/Q42.HueApi/Models/Groups/DefaultHueResult.cs +++ b/src/Q42.HueApi/Models/Groups/DefaultHueResult.cs @@ -13,7 +13,7 @@ namespace Q42.HueApi.Models.Groups /// /// A PUT or POST returns a list which can contain multiple success and errors /// - public class HueResults : BlockingCollection + public class HueResults : List { public bool HasErrors()