我在我的C#应用程序上运行的多个线程,每个线程这些线程的访问TextBox
记录的事件。当我CheckForIllegalCrossThreadCalls属性设置为false
,我能够阻止许多跨线程错误:禁用“CheckForIllegalCrossThreadCalls”是阻止跨线程错误的好方法吗?
System.InvalidOperationException: Cross-thread operation not valid: Control 'myTextBox'
accessed from a thread other than the thread it was created on.
,这是什么问题的最佳解决方案?使用代表或禁用CheckForIllegalCrossThreadCalls
,因为我试过了?许多文章说,禁用CheckForIllegalCrossThreadCalls
不是一个好的编程习惯。