DispatcherObject.VerifyAccess Metodo

Definizione

Impone che il thread chiamante abbia accesso a DispatcherObject.

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

Eccezioni

Il thread chiamante non ha accesso a DispatcherObject.

Esempio

Nell'esempio seguente viene VerifyAccess usato per determinare se un thread ha accesso al thread in cui è stato creato un oggetto Button . Se il thread chiamante non ha accesso, viene generata un'eccezione InvalidOperationException .

// 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)

Commenti

Solo il thread Dispatcher in cui è stato creato può accedere a DispatcherObject.

Qualsiasi thread può verificare se ha accesso a questo DispatcherObjectoggetto .

La differenza tra CheckAccess e VerifyAccess è che CheckAccess restituisce un valore booleano che specifica se il thread chiamante ha accesso a questo DispatcherObject oggetto e VerifyAccess genera un'eccezione se il thread chiamante non ha accesso all'oggetto DispatcherObject.

Si applica a