|
@@ -4309,7 +4309,7 @@ namespace TeamAAS_VP.Core
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// 定时将消息队列批量推送到 UI 线程,200ms 一次
|
|
/// 定时将消息队列批量推送到 UI 线程,200ms 一次
|
|
|
- /// 使用 DispatcherPriority.Background + 分批出让,避免 WPF 布局洪水饿死用户输入
|
|
|
|
|
|
|
+ /// 使用 DispatcherPriority.Background 避免抢占比用户输入更高优先级的操作
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
private void FlushMessageQueue()
|
|
private void FlushMessageQueue()
|
|
|
{
|
|
{
|
|
@@ -4320,18 +4320,12 @@ namespace TeamAAS_VP.Core
|
|
|
batch.Add(item);
|
|
batch.Add(item);
|
|
|
if (batch.Count == 0) return;
|
|
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++)
|
|
for (int i = 0; i < batch.Count; i++)
|
|
|
{
|
|
{
|
|
|
_eventAggregator.GetEvent<TaskMessageNotification>().Publish(batch[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);
|
|
}), System.Windows.Threading.DispatcherPriority.Background);
|
|
|
}
|
|
}
|
|
|
public bool concurrenty = true;
|
|
public bool concurrenty = true;
|