Method BeginInvoke
BeginInvoke(Delegate, object?[])
Executes a delegate asynchronously on the thread that the control was created on.
public virtual IAsyncResult BeginInvoke(Delegate method, object?[] args)
Parameters
methodDelegateA delegate to a method that takes parameters of the same number and type that are contained in the args parameter.
argsobject[]An array of objects to pass as arguments to the given method. This can be
nullif no arguments are needed.
Returns
- IAsyncResult
An IAsyncResult that represents the result of the operation.
BeginInvoke(Delegate)
Executes a delegate asynchronously on the thread that the control was created on.
public virtual IAsyncResult BeginInvoke(Delegate method)
Parameters
methodDelegateA delegate to a method that takes no parameters.
Returns
- IAsyncResult
An IAsyncResult that represents the result of the operation.
BeginInvoke(Action)
Executes an action asynchronously on the thread that the control was created on.
public virtual IAsyncResult BeginInvoke(Action action)
Parameters
actionActionAn action to execute.
Returns
- IAsyncResult
An IAsyncResult that represents the result of the operation.
Examples
private void StartCounterThread1() { var thread1 = new Thread(() => { for (int i = 0; ; i++) { BeginInvoke(() => beginInvokeCounterLabel.Text = i.ToString()); Thread.Sleep(1000); } }) { IsBackground = true };
thread1.Start(); }
Remarks
You can call this method from another non-ui thread with action which can perform operation on ui controls.