DispatcherObject.VerifyAccess Method

Definition

Impõe que o thread de chamada tenha acesso a este DispatcherObject.Enforces that the calling thread has access to this DispatcherObject.

public:
 void VerifyAccess();
public void VerifyAccess ();
member this.VerifyAccess : unit -> unit
Public Sub VerifyAccess ()

Exceptions

O thread de chamada não tem acesso a este DispatcherObject.the calling thread does not have access to this DispatcherObject.

Examples

O exemplo a seguir usa VerifyAccess para determinar se um thread tem acesso ao thread em que um Button foi criado.The following example uses VerifyAccess to determine whether a thread has access to the thread that a Button was created on. Se o thread de chamada não tiver acesso, um InvalidOperationException será gerado.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)

Remarks

Somente o thread no qual o Dispatcher foi criado pode acessar o DispatcherObject.Only the thread the Dispatcher was created on may access the DispatcherObject.

Qualquer thread pode verificar se ele tem acesso a esse DispatcherObject.Any thread can check to see whether it has access to this DispatcherObject.

A diferença entre CheckAccess e VerifyAccess é que CheckAccess retorna um booliano que especifica se o thread de chamada tem acesso a esse DispatcherObject e VerifyAccess gera uma exceção se o thread de chamada não tem acesso a esse 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.

Applies to