Skip to content

Commit

Permalink
Only use blocking collection in SendCommandRawAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Apr 19, 2021
1 parent 6049017 commit ad7379b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/Q42.HueApi/HueClient-Lights.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Dynamic;
using Q42.HueApi.Models;
using Q42.HueApi.Interfaces;
using System.Collections.Concurrent;

namespace Q42.HueApi
{
Expand Down Expand Up @@ -183,7 +184,7 @@ public async Task<HueResults> SendCommandRawAsync(string command, IEnumerable<st
}
else
{
HueResults results = new HueResults();
BlockingCollection<DefaultHueResult> results = new BlockingCollection<DefaultHueResult>();
HttpClient client = await GetHttpClient().ConfigureAwait(false);

await lightList.ForEachAsync(_parallelRequests, async (lightId) =>
Expand Down Expand Up @@ -213,7 +214,9 @@ await lightList.ForEachAsync(_parallelRequests, async (lightId) =>

}).ConfigureAwait(false);

return results;
HueResults hueResults = new HueResults();
hueResults.AddRange(results);
return hueResults;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Q42.HueApi/Models/Groups/DefaultHueResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Q42.HueApi.Models.Groups
/// <summary>
/// A PUT or POST returns a list which can contain multiple success and errors
/// </summary>
public class HueResults : BlockingCollection<DefaultHueResult>
public class HueResults : List<DefaultHueResult>
{

public bool HasErrors()
Expand Down

0 comments on commit ad7379b

Please sign in to comment.