BeginInvoke 메서드 (Delegate, Object[])
콘텐츠의 테이블 축소
콘텐츠의 테이블 확장
이 문서는 기계로 번역한 것입니다. 원본 텍스트를 보려면 포인터를 문서의 문장 위로 올리십시오. 추가 정보
번역
원본

Control.BeginInvoke 메서드 (Delegate, Object[])

 

컨트롤의 내부 핸들이 작성된 스레드에서 특정 인수를 사용하여 지정된 대리자를 비동기식으로 실행합니다.

네임스페이스:   System.Windows.Forms
어셈블리:  System.Windows.Forms.dll의 System.Windows.Forms

public IAsyncResult BeginInvoke(
	Delegate method,
	params object[] args
)

매개 변수

method

args 매개 변수에 있는 매개 변수의 수 및 형식과 동일한 매개 변수를 갖는 메서드의 대리자입니다.

args

주어진 메서드에 인수로 전달하는 개체의 배열입니다.인수가 필요하지 않으면 null일 수 있습니다.

반환 값

Type: System.IAsyncResult

IAsyncResult 작업의 결과를 나타내는 BeginInvoke입니다.

Exception Condition
InvalidOperationException

No appropriate window handle can be found.

The delegate is called asynchronously, and this method returns immediately.You can call this method from any thread, even the thread that owns the control's handle.If the control's handle does not exist yet, this method searches up the control's parent chain until it finds a control or form that does have a window handle.If no appropriate handle can be found, BeginInvoke will throw an exception.Exceptions within the delegate method are considered untrapped and will be sent to the application's untrapped exception handler.

You can call EndInvoke to retrieve the return value from the delegate, if neccesary, but this is not required. EndInvoke will block until the return value can be retrieved.

System_CAPS_note참고

Most methods on a control can only be called from the thread where the control was created.In addition to the InvokeRequired property, there are four methods on a control that are thread safe: Invoke, BeginInvoke, EndInvoke, and CreateGraphics if the handle for the control has already been created.Calling CreateGraphics before the control's handle has been created on a background thread can cause illegal cross thread calls.For all other method calls, you should use one of the invoke methods to marshal the call to the control's thread.The invoke methods always invoke their callbacks on the control's thread.

System_CAPS_note참고

An exception might be thrown if the thread that should process the message is no longer active.

The following code example demonstrates a use of the BeginInvoke method.

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);
}

.NET Framework
1.1 이후에 사용 가능
맨 위로 이동
표시:
© 2016 Microsoft