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 자동화 클라이언트는 모달 대화 상자가 닫힐 때까지 차단된 상태로 유지됩니다.

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

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

  • 작업이 완료될 때까지 기다리는 것은 실제로 불가능합니다.

  • 작업에는 사용자 개입이 필요합니다.

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

적용 대상

추가 정보