Object. Verify Access 方法
public: void VerifyAccess();
public void VerifyAccess ();
member this.VerifyAccess : unit -> unit
Public Sub VerifyAccess ()
下面的示例使用VerifyAccess来确定线程是否有权访问在上创建的线程Button 。The following example uses VerifyAccess to determine whether a thread has access to the thread that a Button was created on. 如果调用线程没有访问权限, InvalidOperationException则会引发。If the calling thread does not have access, an InvalidOperationException is thrown.
// Check if this thread has access to this object. theButton.VerifyAccess(); // Thread has access to the object, so update the UI. UpdateButtonUI(theButton);
' Check if this thread has access to this object. theButton.VerifyAccess() ' Thread has access to the object, so update the UI. UpdateButtonUI(theButton)
与CheckAccess CheckAccess DispatcherObject之间的区别在于, 返回一个布尔值, 该值指定调用线程是否有权访问此VerifyAccess值, 如果调用线程不具有访问权限, 则会引发异常。 VerifyAccess此DispatcherObject。The difference between CheckAccess and VerifyAccess is that CheckAccess returns a Boolean that specifies whether the calling thread has access to this DispatcherObject and VerifyAccess throws an exception if the calling thread does not have access to the this DispatcherObject.