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

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

问题描述

在WinForms应用程序中,仅设置

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天全站免登陆