Control.BeginInvoke 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
컨트롤의 기본 핸들이 만들어진 스레드에서 대리자를 비동기적으로 실행합니다.
오버로드
| Name | Description |
|---|---|
| BeginInvoke(Delegate, Object[]) |
컨트롤의 기본 핸들이 만들어진 스레드에서 지정된 인수를 사용하여 지정된 대리자를 비동기적으로 실행합니다. |
| BeginInvoke(Action) |
컨트롤의 기본 핸들이 만들어진 스레드에서 지정된 대리자를 비동기적으로 실행합니다. |
| BeginInvoke(Delegate) |
컨트롤의 기본 핸들이 만들어진 스레드에서 지정된 대리자를 비동기적으로 실행합니다. |
BeginInvoke(Delegate, Object[])
- Source:
- Control.cs
- Source:
- Control.cs
- Source:
- Control.cs
- Source:
- Control.cs
- Source:
- Control.cs
컨트롤의 기본 핸들이 만들어진 스레드에서 지정된 인수를 사용하여 지정된 대리자를 비동기적으로 실행합니다.
public:
virtual IAsyncResult ^ BeginInvoke(Delegate ^ method, cli::array <System::Object ^> ^ args);
public:
virtual IAsyncResult ^ BeginInvoke(Delegate ^ method, ... cli::array <System::Object ^> ^ args);
public IAsyncResult BeginInvoke(Delegate method, object[] args);
public IAsyncResult BeginInvoke(Delegate method, params object[] args);
public IAsyncResult BeginInvoke(Delegate method, params object?[]? args);
abstract member BeginInvoke : Delegate * obj[] -> IAsyncResult
override this.BeginInvoke : Delegate * obj[] -> IAsyncResult
Public Function BeginInvoke (method As Delegate, args As Object()) As IAsyncResult
Public Function BeginInvoke (method As Delegate, ParamArray args As Object()) As IAsyncResult
매개 변수
- method
- Delegate
매개 변수에 포함된 동일한 숫자 및 형식의 매개 변수를 사용하는 메서드에 대한 args 대리자입니다.
- args
- Object[]
지정된 메서드에 인수로 전달할 개체의 배열입니다. 인수가 null 필요하지 않은 경우일 수 있습니다.
반환
IAsyncResult 작업의 결과를 나타내는 값입니다BeginInvoke(Delegate).
구현
예외
적절한 창 핸들을 찾을 수 없습니다.
예제
다음 코드 예제에서는 메서드를 사용하는 방법을 보여 줍니다 BeginInvoke .
private:
delegate void MyDelegate(
Label^ myControl, String^ myArg2 );
void Button_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
array<Object^>^myArray = gcnew array<Object^>(2);
myArray[ 0 ] = gcnew Label;
myArray[ 1 ] = "Enter a Value";
myTextBox->BeginInvoke( gcnew MyDelegate( this, &MyForm::DelegateMethod ), myArray );
}
void DelegateMethod( Label^ myControl, String^ myCaption )
{
myControl->Location = Point(16,16);
myControl->Size = System::Drawing::Size( 80, 25 );
myControl->Text = myCaption;
this->Controls->Add( myControl );
}
delegate void InvokeDelegate();
public delegate void MyDelegate(Label myControl, string myArg2);
private void Button_Click(object sender, EventArgs e)
{
object[] myArray = new object[2];
myArray[0] = new Label();
myArray[1] = "Enter a Value";
myTextBox.BeginInvoke(new MyDelegate(DelegateMethod), myArray);
}
public void DelegateMethod(Label myControl, string myCaption)
{
myControl.Location = new Point(16,16);
myControl.Size = new Size(80, 25);
myControl.Text = myCaption;
this.Controls.Add(myControl);
}
Delegate Sub MyDelegate(myControl As Label, myArg2 As String)
Private Sub Button_Click(sender As Object, e As EventArgs)
Dim myArray(1) As Object
myArray(0) = New Label()
myArray(1) = "Enter a Value"
myTextBox.BeginInvoke(New MyDelegate(AddressOf DelegateMethod), myArray)
End Sub
Public Sub DelegateMethod(myControl As Label, myCaption As String)
myControl.Location = New Point(16, 16)
myControl.Size = New Size(80, 25)
myControl.Text = myCaption
Me.Controls.Add(myControl)
End Sub
설명
대리자는 비동기적으로 호출되고 이 메서드는 즉시 반환됩니다. 컨트롤의 핸들을 소유하는 스레드도 스레드에서 이 메서드를 호출할 수 있습니다. 컨트롤의 핸들이 아직 없는 경우 이 메서드는 창 핸들이 있는 컨트롤 또는 폼을 찾을 때까지 컨트롤의 부모 체인을 검색합니다. 적절한 핸들을 찾을 BeginInvoke 수 없는 경우 예외가 throw됩니다. 대리자 메서드 내의 예외는 래핑되지 않은 것으로 간주되며 애플리케이션의 래핑되지 않은 예외 처리기로 전송됩니다.
대리자에서 반환 값을 검색하기 위해 호출 EndInvoke 할 수 있지만 필수는 아닙니다. EndInvoke 는 반환 값을 검색할 수 있을 때까지 차단됩니다.
메모
컨트롤의 대부분의 메서드는 컨트롤이 만들어진 스레드에서만 호출할 수 있습니다. 속성 외에도 InvokeRequired 스레드로부터 안전한 Invoke네 가지 메서드가 컨트롤에 있습니다. , BeginInvoke및 EndInvokeCreateGraphics 컨트롤에 대한 핸들이 이미 만들어진 경우. 백그라운드 스레드에서 컨트롤의 핸들을 만들기 전에 호출 CreateGraphics 하면 잘못된 스레드 간 호출이 발생할 수 있습니다. 다른 모든 메서드 호출의 경우 호출 메서드 중 하나를 사용하여 컨트롤의 스레드에 대한 호출을 마샬링해야 합니다. 호출 메서드는 항상 컨트롤의 스레드에서 해당 콜백을 호출합니다.
메모
메시지를 처리해야 하는 스레드가 더 이상 활성 상태가 아니면 예외가 throw될 수 있습니다.
추가 정보
적용 대상
BeginInvoke(Action)
- Source:
- Control.cs
- Source:
- Control.cs
- Source:
- Control.cs
- Source:
- Control.cs
- Source:
- Control.cs
컨트롤의 기본 핸들이 만들어진 스레드에서 지정된 대리자를 비동기적으로 실행합니다.
public:
IAsyncResult ^ BeginInvoke(Action ^ method);
public IAsyncResult BeginInvoke(Action method);
member this.BeginInvoke : Action -> IAsyncResult
Public Function BeginInvoke (method As Action) As IAsyncResult
매개 변수
- method
- Action
매개 변수를 사용하지 않는 메서드에 대한 대리자입니다.
반환
IAsyncResult 작업의 결과를 나타내는 값입니다BeginInvoke(Action).
적용 대상
BeginInvoke(Delegate)
- Source:
- Control.cs
- Source:
- Control.cs
- Source:
- Control.cs
- Source:
- Control.cs
- Source:
- Control.cs
컨트롤의 기본 핸들이 만들어진 스레드에서 지정된 대리자를 비동기적으로 실행합니다.
public:
IAsyncResult ^ BeginInvoke(Delegate ^ method);
public IAsyncResult BeginInvoke(Delegate method);
member this.BeginInvoke : Delegate -> IAsyncResult
Public Function BeginInvoke (method As Delegate) As IAsyncResult
매개 변수
- method
- Delegate
매개 변수를 사용하지 않는 메서드에 대한 대리자입니다.
반환
IAsyncResult 작업의 결과를 나타내는 값입니다BeginInvoke(Delegate).
예외
적절한 창 핸들을 찾을 수 없습니다.
예제
다음 코드 예제에서는 메서드를 사용하는 방법을 보여 줍니다 BeginInvoke .
private:
void Invoke_Click( Object^ /*sender*/, EventArgs^ /*e*/ )
{
myTextBox->BeginInvoke( gcnew InvokeDelegate( this, &MyForm::InvokeMethod ) );
}
void InvokeMethod()
{
myTextBox->Text = "Executed the given delegate";
}
public delegate void InvokeDelegate();
private void Invoke_Click(object sender, EventArgs e)
{
myTextBox.BeginInvoke(new InvokeDelegate(InvokeMethod));
}
public void InvokeMethod()
{
myTextBox.Text = "Executed the given delegate";
}
Delegate Sub InvokeDelegate()
Private Sub Invoke_Click(sender As Object, e As EventArgs)
myTextBox.BeginInvoke(New InvokeDelegate(AddressOf InvokeMethod))
End Sub
Public Sub InvokeMethod()
myTextBox.Text = "Executed the given delegate"
End Sub
설명
대리자는 비동기적으로 호출되고 이 메서드는 즉시 반환됩니다. 컨트롤의 핸들을 소유하는 스레드도 스레드에서 이 메서드를 호출할 수 있습니다. 컨트롤의 핸들이 아직 없는 경우 이 메서드는 창 핸들이 있는 컨트롤 또는 폼을 찾을 때까지 컨트롤의 부모 체인을 검색합니다. 적절한 핸들을 찾을 BeginInvoke 수 없는 경우 예외가 throw됩니다. 대리자 메서드 내의 예외는 래핑되지 않은 것으로 간주되며 애플리케이션의 래핑되지 않은 예외 처리기로 전송됩니다.
대리자에서 반환 값을 검색하기 위해 호출 EndInvoke 할 수 있지만 필수는 아닙니다. EndInvoke 는 반환 값을 검색할 수 있을 때까지 차단됩니다.
메모
컨트롤의 대부분의 메서드는 컨트롤이 만들어진 스레드에서만 호출할 수 있습니다. 속성 외에도 InvokeRequired 스레드로부터 안전한 Invoke네 가지 메서드가 컨트롤에 있습니다. , BeginInvoke및 EndInvokeCreateGraphics 컨트롤에 대한 핸들이 이미 만들어진 경우. 백그라운드 스레드에서 컨트롤의 핸들을 만들기 전에 호출 CreateGraphics 하면 잘못된 스레드 간 호출이 발생할 수 있습니다. 다른 모든 메서드 호출의 경우 호출 메서드 중 하나를 사용하여 컨트롤의 스레드에 대한 호출을 마샬링해야 합니다. 호출 메서드는 항상 컨트롤의 스레드에서 해당 콜백을 호출합니다.
메모
메시지를 처리해야 하는 스레드가 더 이상 활성 상태가 아니면 예외가 throw될 수 있습니다.