C# .NET WPF 应用程序随机挂起 (WgxConnection_ShouldForceSoftwareForGraphicsStreamClient)

Mat*_*s G 5 .net c# wpf mvvm

我使用以下库编写了一个 WPF .NET 应用程序 (.NET 4.5):

  • 系统.Windows.Interactivity.dll
  • Microsoft.Practices.ServiceLocation.dll
  • GalaSoft.MvvmLight.Platform.dll
  • GalaSoft.MvvmLight.Extras.dll
  • GalaSoft.MvvmLight.dll

我使用 2 个计时器:

  • System.Threading.DispatcherTimer(每 200 毫秒一次)

    • 只需将绑定到标签的 DateTime 属性设置为 DateTime.Now。
  • System.Timers.Timer(每秒滴答一次)

    • 将焦点设置到文本框,从 Web 服务请求数据(在异步任务中)
    • 更新绑定到 Datagrid 的 ICollectionView(使用 Application.Current.Dispatcher.BeginInvoke

该应用程序在大约 50 台 Windows 7 计算机上运行(从早上 7 点到下午 5 点)没有任何问题。

在只有 1 台 Windows 7 机器上,它只是随机冻结,CPU 使用率高且只有一个活动线程:WgxConnection_ShouldForceSoftwareForGraphicsStreamClient

Windows 事件日志中没有任何条目,也没有触发此事件的用户事件。

我找不到任何关于此的信息WgxConnection...有人有什么想法吗?

编辑:

刚刚找到片段“UnsafeNativeMethods.WgxConnection_ShouldForceSoftwareForGraphicsStreamClient();” 在 MediaSystem.cs 中: https://referencesource.microsoft.com/#PresentationCore/Core/CSharp/System/windows/Media/MediaSystem.cs

--> wpfgfx_v0400.dll

也许“RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;” 可以改变行为吗?

小智 0

如果不看代码示例,很难识别问题。

这是我能想到的几点

  1. 重新访问代码并查看是否有任何阻塞代码。请注意,由于您正在使用计时器,因此必须使用线程安全列表实现(ConcurrentQueue、ConcurrentStack、ConcurrentBag)。
  2. 如果它在除一台台式机之外的所有台式机上运行良好,请查看该 PC 是否有不同的 GPU。WPF 和可用的 GPU 驱动程序之间可能存在一些不兼容性。
  3. 尝试使用 Dispatcher 计时器而不是 System.Timers.Timer。