仅将 CheckForIllegalCrossThreadCalls 设置为 false 以避免在调试期间出现跨线程错误是否安全? [英] Is it safe just to set CheckForIllegalCrossThreadCalls to false to avoid cross threading errors during debugging?

查看:29
本文介绍了仅将 CheckForIllegalCrossThreadCalls 设置为 false 以避免在调试期间出现跨线程错误是否安全?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 WinForms 应用程序中,仅设置 CheckForIllegalCrossThreadCalls 为 FALSE 以避免调试过程中出现跨线程错误?

In WinForms applications, is it safe just to set CheckForIllegalCrossThreadCalls to FALSE to avoid cross threading errors during debugging?

CheckForIllegalCrossThreadCalls = false;

推荐答案

不,那不安全.检查线程错误的 Winforms 代码非常很重要,导致的问题极难诊断.最大的问题是它不会导致持续失败,您的应用程序将随机出现异常行为,每月仅发生一次死锁或崩溃.或者根本不做,直到您做出微小的改变.或者只在特定用户的机器上,你会责怪用户而不是你的代码.

No, that's not safe. The Winforms code that checks for threading mistakes is very important, the trouble that causes is extremely hard to diagnose. The biggest problem is that it doesn't cause consistent failure, your app will misbehave randomly and deadlock or crash only once a month. Or never at all, until you make a minor change. Or only on a particular user's machine, you'll blame the user instead of your code.

首先存在 CheckForIllegalCrossThreadCalls 属性的唯一原因是为了保持 .NET 2.0 及更高版本与未执行此线程安全测试的有问题的 .NET 1.x 程序兼容.错误的向后兼容性;-P

The only reason the CheckForIllegalCrossThreadCalls property exists in the first place is to keep .NET 2.0 and up compatible with buggy .NET 1.x programs where this threading safety test was not performed. Backward compatibility for bugs ;-P

这篇关于仅将 CheckForIllegalCrossThreadCalls 设置为 false 以避免在调试期间出现跨线程错误是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆