共用方式為


AutomationInteropProvider.ClientsAreListening 屬性

定義

取得值,指定是否訂閱任何消費者介面自動化用戶端應用程式消費者介面自動化事件。

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

適用於

另請參閱