このブラウザーはサポートされなくなりました。

Microsoft Edge にアップグレードすると、最新の機能、セキュリティ更新プログラム、およびテクニカル サポートを利用できます。

Microsoft Edge をダウンロードする Internet Explorer と Microsoft Edge の詳細情報
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

Parameters

An array of objects to pass as arguments to the given method. This can be null if no arguments are needed.

Returns

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

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
    	

Remarks

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.

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.

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

public:
 IAsyncResult ^ BeginInvoke(Action ^ method);
public IAsyncResult BeginInvoke (Action method);
member this.BeginInvoke : Action -> IAsyncResult
Public Function BeginInvoke (method As Action) As IAsyncResult

Parameters

public:
 IAsyncResult ^ BeginInvoke(Delegate ^ method);
public IAsyncResult BeginInvoke (Delegate method);
member this.BeginInvoke : Delegate -> IAsyncResult
Public Function BeginInvoke (method As Delegate) As IAsyncResult

Parameters

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

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
    	

Remarks

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.

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.

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

以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「https://aka.ms/ContentUserFeedback」を参照してください。

フィードバックの送信と表示