Ver Fonte

fix: FlushMessageQueue改用BeginInvoke+Background优先级,修复编译错误

zly há 2 meses atrás
pai
commit
2a8c728bc4
1 ficheiros alterados com 2 adições e 8 exclusões
  1. 2 8
      TeamAAS-VM/Core/Management.cs

+ 2 - 8
TeamAAS-VM/Core/Management.cs

@@ -4309,7 +4309,7 @@ namespace TeamAAS_VP.Core
 
         /// <summary>
         /// 定时将消息队列批量推送到 UI 线程,200ms 一次
-        /// 使用 DispatcherPriority.Background + 分批出让,避免 WPF 布局洪水饿死用户输入
+        /// 使用 DispatcherPriority.Background 避免抢占比用户输入更高优先级的操作
         /// </summary>
         private void FlushMessageQueue()
         {
@@ -4320,18 +4320,12 @@ namespace TeamAAS_VP.Core
                 batch.Add(item);
             if (batch.Count == 0) return;
 
-            // InvokeAsync 配合 async Task 避免 async void 陷阱;
-            // Background 优先级确保用户输入(Input 优先级)优先处理
-            App.Current.Dispatcher.InvokeAsync(async () =>
+            App.Current.Dispatcher.BeginInvoke(new Action(() =>
             {
                 for (int i = 0; i < batch.Count; i++)
                 {
                     _eventAggregator.GetEvent<TaskMessageNotification>().Publish(batch[i]);
-                    // 每 5 条出让 UI 线程,让 WPF 布局和用户输入有机会执行
-                    if (i % 5 == 4 && i < batch.Count - 1)
-                        await System.Windows.Threading.Dispatcher.Yield(System.Windows.Threading.DispatcherPriority.Input);
                 }
-
             }), System.Windows.Threading.DispatcherPriority.Background);
         }
         public bool concurrenty = true;