InvokePattern.Invoke 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컨트롤을 활성화하고 명확한 단일 작업을 시작하는 요청을 보냅니다.
public:
void Invoke();
public void Invoke();
member this.Invoke : unit -> unit
Public Sub Invoke ()
예외
요소는 컨트롤 패턴을 지원하지 InvokePattern 않거나 숨겨지거나 차단됩니다.
요소를 사용할 수 없습니다. UI 자동화 공급자가 IsEnabled 속성의 자체 처리를 구현한 경우 발생할 수 있습니다.
예제
다음 예제 InvokePattern 에서는 컨트롤에서 컨트롤 패턴을 가져오고 메서드가 Invoke 호출됩니다.
///--------------------------------------------------------------------
/// <summary>
/// Obtains an InvokePattern control pattern from a control
/// and calls the InvokePattern.Invoke() method on the control.
/// </summary>
/// <param name="targetControl">
/// The control of interest.
/// </param>
///--------------------------------------------------------------------
private void InvokeControl(AutomationElement targetControl)
{
InvokePattern invokePattern = null;
try
{
invokePattern =
targetControl.GetCurrentPattern(InvokePattern.Pattern)
as InvokePattern;
}
catch (ElementNotEnabledException)
{
// Object is not enabled
return;
}
catch (InvalidOperationException)
{
// object doesn't support the InvokePattern control pattern
return;
}
invokePattern.Invoke();
}
'''--------------------------------------------------------------------
''' <summary>
''' Obtains an InvokePattern control pattern from a control
''' and calls the InvokePattern.Invoke() method on the control.
''' </summary>
''' <param name="targetControl">
''' The control of interest.
''' </param>
'''--------------------------------------------------------------------
Private Sub InvokeControl(ByVal targetControl As AutomationElement)
Dim invokePattern As InvokePattern = Nothing
Try
invokePattern = _
DirectCast(targetControl.GetCurrentPattern(invokePattern.Pattern), _
InvokePattern)
Catch e As ElementNotEnabledException
' Object is not enabled.
Return
Catch e As InvalidOperationException
' Object doesn't support the InvokePattern control pattern
Return
End Try
invokePattern.Invoke()
End Sub
설명
호출은 Invoke 차단 없이 즉시 반환되어야 합니다. 그러나 이 동작은 전적으로 Microsoft UI 자동화 공급자 구현에 따라 달라집니다. 호출 Invoke 로 인해 차단 문제(예: 모달 대화 상자)가 발생하는 시나리오에서는 메서드를 호출하는 데 별도의 도우미 스레드가 필요할 수 있습니다.