.net - 几个小时的空闲时间后,用户控件重新启动(卸载+加载)
问题描述
这真是一件奇怪的事情。我有一个 WPF 应用程序,它加载一个仅包含一些图像的 UserControl。在幕后,此应用程序从各种 PerformanceCounter 收集数据,并每秒将数据写入磁盘。但是,如果我让应用程序在夜间运行,它将在大约 9 小时后卸载并重新加载用户控件(这不是固定的,而是大约在那个时间)。从 UserControl_Unloaded 事件中收集的堆栈跟踪中,我只看到有一个广播要卸载......
UNLOAD: at PerformanceCollector.Controls.MenuControl.UserControl_Unloaded(Object sender, RoutedEventArgs e)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
at System.Windows.BroadcastEventHelper.BroadcastUnloadedEvent(Object root)
at MS.Internal.LoadedOrUnloadedOperation.DoWork()
我完全不明白为什么会这样。CPU和内存坚如磐石。固定电脑没有在睡觉或任何东西。VS 异常设置中的所有内容都已勾选,因此不会发生错误。这里有两个奇怪的东西,为什么卸载,为什么又加载?但我将专注于理解为什么它会卸载并从那里开始。
有谁知道如何追求这个?我需要找出 BroadcastUnloadedEvent 的来源。WPF/.NET 中是否存在我缺少的“空闲”行为?一些我可以挂钩的事件或我可以使用的监控选项?在这里抓着稻草...
Windows 10、Visual Studio 2019、.NET 4.7.2。
解决方案
推荐阅读
- javascript - 在完成 for 循环之前 Promise 拒绝
- django - 基于尚未加载的数据的模型中的Django默认值
- python - pandas cumsum gt 结果分配回原始数据帧
- php - 如果只打印,我是否需要对表格进行消毒?
- typescript - 有没有办法在没有显式类型的情况下使用泛型类型?
- java - 从无限循环中读取流
- c++ - 在 std::thread 或 pthread_create 中创建的 QObject 的 QThreadData 是什么
- ios - 如何通过协调器模式将值从第二个视图控制器传递到第一个视图控制器
- python - 如何改进我的 CNN?高且持续的验证错误
- powershell - 在 Powershell 的条件语句中使用时间