DispatcherObject.VerifyAccess Metodo

Definizione

Impone che il thread chiamante abbia accesso a DispatcherObject.

C#
public void 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 .

C#
// 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

Prodotto Versioni
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
Windows Desktop 3.0, 3.1, 5, 6, 7