mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-20 07:56:50 +00:00
fix: copy dictionaries
- fixed multiple enumeration exception
This commit is contained in:
parent
6a33e7c99d
commit
bce1e3610e
1 changed files with 7 additions and 2 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
@ -39,10 +40,14 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
||||||
|
|
||||||
sourceDevice.CurrentSourcesChanged += (sender, e) =>
|
sourceDevice.CurrentSourcesChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
|
// need to copy the dictionaries to avoid enumeration issues
|
||||||
|
var currentSourceKeys = sourceDevice.CurrentSourceKeys.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
|
var currentSources = sourceDevice.CurrentSources.ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
|
||||||
|
|
||||||
PostStatusMessage(JToken.FromObject(new
|
PostStatusMessage(JToken.FromObject(new
|
||||||
{
|
{
|
||||||
currentSourceKeys = sourceDevice.CurrentSourceKeys,
|
currentSourceKeys,
|
||||||
currentSources = sourceDevice.CurrentSources
|
currentSources,
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue