AutomationInteropProvider.ClientsAreListening 属性

定义

获取一个值,该值指定是否订阅任何UI 自动化客户端应用程序UI 自动化事件。

public:
 static property bool ClientsAreListening { bool get(); };
public static bool ClientsAreListening { get; }
member this.ClientsAreListening : bool
Public Shared ReadOnly Property ClientsAreListening As Boolean

属性值

Boolean

如果客户端订阅事件,则为 true;否则为 false

示例

/// <summary>
/// Raises an event when a control is invoked.
/// </summary>
/// <param name="provider">The UI Automation provider for the control.</param>
private void RaiseInvokeEvent(IRawElementProviderSimple provider)
{
    if (AutomationInteropProvider.ClientsAreListening)
    {
        AutomationEventArgs args = 
            new AutomationEventArgs(InvokePatternIdentifiers.InvokedEvent);
        AutomationInteropProvider.RaiseAutomationEvent(InvokePatternIdentifiers.InvokedEvent, 
            provider, args);
    }
}
''' <summary>
''' Raises an event when a control is invoked.
''' </summary>
''' <param name="provider">The UI Automation provider for the control.</param>
Private Sub RaiseInvokeEvent(ByVal provider As IRawElementProviderSimple)
    If AutomationInteropProvider.ClientsAreListening Then
        Dim args As New AutomationEventArgs(InvokePatternIdentifiers.InvokedEvent)
        AutomationInteropProvider.RaiseAutomationEvent(InvokePatternIdentifiers.InvokedEvent, provider, args)
    End If

End Sub

适用于

另请参阅