Control.CheckForIllegalCrossThreadCalls 属性


获取或设置一个值,该值指示是否捕获对错误线程的调用,这些调用在调试应用程序时访问控件的 Handle 属性。Gets or sets a value indicating whether to catch calls on the wrong thread that access a control's Handle property when an application is being debugged.

 static property bool CheckForIllegalCrossThreadCalls { bool get(); void set(bool value); };
public static bool CheckForIllegalCrossThreadCalls { get; set; }
member this.CheckForIllegalCrossThreadCalls : bool with get, set
Public Shared Property CheckForIllegalCrossThreadCalls As Boolean


如果捕获了对错误线程的调用,则为 true;否则为 falsetrue if calls on the wrong thread are caught; otherwise, false.



当某个线程不是控件的创建线程尝试访问该控件的一个或多个属性时,这通常会导致不可预知的结果。When a thread other than the creating thread of a control tries to access one of that control's methods or properties, it often leads to unpredictable results. 常见的无效线程活动是对访问控件的 Handle 属性的错误线程的调用。A common invalid thread activity is a call on the wrong thread that accesses the control's Handle property. CheckForIllegalCrossThreadCalls 设置为 true 可在调试时更轻松地查找和诊断此线程活动。Set CheckForIllegalCrossThreadCalls to true to find and diagnose this thread activity more easily while debugging.