diff --git a/src/SparkplugNet/VersionB/SparkplugApplication.cs b/src/SparkplugNet/VersionB/SparkplugApplication.cs
index 76f896b..c755cfe 100644
--- a/src/SparkplugNet/VersionB/SparkplugApplication.cs
+++ b/src/SparkplugNet/VersionB/SparkplugApplication.cs
@@ -210,7 +210,7 @@ await this.FireDeviceBirthReceived(topic.GroupIdentifier, topic.EdgeNodeIdentifi
/// The metric status.
/// Thrown if the edge node identifier is invalid.
/// Thrown if the metric cast is invalid.
- private IEnumerable ProcessPayload(SparkplugMessageTopic topic, List metrics, SparkplugMetricStatus metricStatus)
+ private List ProcessPayload(SparkplugMessageTopic topic, List metrics, SparkplugMetricStatus metricStatus)
{
var metricState = new MetricState
{
@@ -224,13 +224,34 @@ private IEnumerable ProcessPayload(SparkplugMessageTopic topic, List {
+ metricState = previousMetricState;
+ metricState.MetricStatus = metricStatus;
+ return metricState;
+ });
}
else
{
- this.NodeStates[topic.EdgeNodeIdentifier] = metricState;
+ metricState = new MetricState
+ {
+ MetricStatus = metricStatus
+ };
+ this.NodeStates.AddOrUpdate(
+ topic.EdgeNodeIdentifier,
+ metricState,
+ (_, previousMetricState) =>
+ {
+ metricState = previousMetricState;
+ metricState.MetricStatus = metricStatus;
+ return metricState;
+ }
+ );
}
+ var result = new List();
foreach (var payloadMetric in metrics)
{
if (payloadMetric is not Metric convertedMetric)
@@ -243,7 +264,9 @@ private IEnumerable ProcessPayload(SparkplugMessageTopic topic, List