diff --git a/App.xaml.cs b/App.xaml.cs index d22c1a0..a24a631 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -81,7 +81,7 @@ public partial class App : Application services.AddSingleton(); services.AddSingleton(); services.AddHostedService(); // Register as HostedService - // services.AddHostedService(); + services.AddHostedService(); services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); diff --git a/Services/MqttBackgroundService.cs b/Services/MqttBackgroundService.cs index 6037240..13945be 100644 --- a/Services/MqttBackgroundService.cs +++ b/Services/MqttBackgroundService.cs @@ -129,7 +129,7 @@ namespace PMSWPF.Services // 发布MQTT消息。 await client.PublishAsync(message); - NlogHelper.Info($"Published {variable.Name} = {variable.DataValue} to {topic}/{variable.Name}"); // 记录发布信息 + NlogHelper.Info($"Published {variable.Name} = {variable.DataValue} to {topic}/{variable.Name}",throttle:true); // 记录发布信息 variable.IsModified = false; // 发布后重置修改标志。 } }