DispatcherObject.VerifyAccess Méthode

Définition

Garantit que le thread appelant a accès à DispatcherObject.

C#
public void VerifyAccess ();

Exceptions

le thread appelant n'a pas accès à DispatcherObject.

Exemples

L’exemple suivant utilise VerifyAccess pour déterminer si un thread a accès au thread sur lequel un Button thread a été créé. Si le thread appelant n’a pas accès, une InvalidOperationException exception est levée.

C#
// Check if this thread has access to this object.
theButton.VerifyAccess();

// Thread has access to the object, so update the UI.
UpdateButtonUI(theButton);

Remarques

Seul le thread sur lequel l’utilisateur Dispatcher a été créé peut accéder à .DispatcherObject

N’importe quel thread peut vérifier s’il a accès à ce DispatcherObjectfichier .

La différence entre CheckAccess et VerifyAccess est qu’elle CheckAccess retourne une valeur booléenne qui spécifie si le thread appelant a accès à ce DispatcherObject thread et VerifyAccess lève une exception si le thread appelant n’a pas accès à ce DispatcherObjectthread .

S’applique à

Produit Versions
.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