为什么我的 .Net/WinForms 应用程序仅在 Visual Studio 中出现跨线程异常?

Why my .Net/WinForms application getting Cross Thread exceptions only in Visual Studio?

我继承了遗留的 Winforms/C# 个应用程序。 该应用程序使用分布在多个选项卡上的几个不同的网格。 为了加快 load time/query 的性能,取数据到 对于数据源是通过生成的线程异步完成的。

2019年运行申请Visual Studio时,我得到了几个交叉线程 异常,因为当数据源为 set/reset 时系统会触发事件。这些 事件当然会在不在主 UI 线程上的事件上触发。

我在 Visual Studio 中调试时只看到这些异常。我知道多年后 过去这样做是很糟糕的IDEA/DESIGN,每当我们遇到实例时,我们 将使用 Invoke()/BeginInvoke() 包装访问。

考虑到当 运行 Visual Studio 之外的应用程序时这些异常被“吃掉”, 现在还是这样吗? .. 或者它被认为是 benign/safe 例外?

I only see these exceptions while debugging in Visual Studio.

因为CheckForIllegalCrossThreadCalls默认为Debugger.IsAttached

Source Code link

I know in years past it was a BAD IDEA/DESIGN to do so and whenever we came across instances, we would wrap access with Invoke()/BeginInvoke()

您仍然应该这样做,或者想出一些其他方法来将更新控件的工作编组到创建控件的线程上

Given these exceptions get "eaten" when running the application outside of Visual Studio, is this still the case?

依旧如此;解决这些问题

or is it considered a benign/safe exception?

我不记得曾经遇到过任何人认为它是..