IInvokeProvider.Invoke 메서드

정의

컨트롤을 활성화하고 명확한 단일 작업을 시작하는 요청을 보냅니다.

public:
 void Invoke();
public void Invoke();
abstract member Invoke : unit -> unit
Public Sub Invoke ()

예외

컨트롤을 사용하도록 설정하지 않은 경우

예제

다음 예제에서는 컨트롤의 Invoke MouseDown 이벤트 처리기에서 메서드를 구현합니다. 클래스가 providerControl 생성될 때 초기화된 멤버 변수라고 가정합니다.

/// <summary>
/// Responds to an InvokePattern.Invoke by simulating a MouseDown event.
/// </summary>
/// <remarks>
/// ProviderControl is a button control object that also implements 
/// IRawElementProviderSimple.
/// </remarks>
void IInvokeProvider.Invoke()
{
    // If the control is not enabled, we're responsible for letting UIAutomation know.
    // It catches the exception and then throws it to the client.
    if (false == (bool)rawElementProvider.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id))
    {
        throw new ElementNotEnabledException();
    }

    // Create arguments for the event. The parameters aren't used.
    MouseEventArgs mouseArgs = new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0);

    // Invoke the MouseDown handler. We cannot call MyControl_MouseDown directly, 
    // because it is illegal to update the UI from a different thread.
    MouseEventHandler onMouseEvent = ProviderControl.RootButtonControl_MouseDown;
    ProviderControl.BeginInvoke(onMouseEvent, new object[] { this, mouseArgs });
    }
}

설명

Invoke 는 비동기 호출이며 차단 없이 즉시 반환해야 합니다.

메모

이 동작은 호출될 때 직접 또는 간접적으로 모달 대화 상자를 시작하는 컨트롤에 특히 중요합니다. 이벤트를 선동한 모든 UI 자동화 클라이언트는 모달 대화 상자가 닫히기 전까지 차단된 상태로 유지됩니다.

Invoke 는 이벤트를 발생합니다 InvokedEvent . 가능하면 컨트롤이 연결된 작업을 완료한 후에 이벤트를 발생시켜야 합니다.

InvokedEvent 는 다음 시나리오에서 요청을 서비스 Invoke 하기 전에 발생해야 합니다.

  • 작업이 완료될 때까지 기다리는 것은 불가능하거나 실용적이지 않습니다.

  • 작업에는 사용자 상호 작용이 필요합니다.

  • 이 작업은 시간이 오래 걸리며 호출 클라이언트가 상당한 시간 동안 차단됩니다.

적용 대상

추가 정보