Could you explain this for me please:
someformobj.BeginInvoke((Action)(() =>
{
someformobj.listBox1.SelectedIndex = 0;
}));
Could you tell me how can I use begininvoke exactly?
What is Action type?
Why there is blank brackets ()?
And what does this mean =>?
Actionis a Type of Delegate provided by the .NET framework. TheActionpoints to a method with no parameters and does not return a value.() =>is lambda expression syntax. Lambda expressions are not of TypeDelegate. Invoke requiresDelegatesoActioncan be used to wrap the lambda expression and provide the expectedTypetoInvoke()Invokecauses saidActionto execute on the thread that created the Control’s window handle. Changing threads is often necessary to avoidExceptions. For example, if one tries to set theRtfproperty on aRichTextBoxwhen an Invoke is necessary, without first calling Invoke, then aCross-thread operation not validexception will be thrown. CheckControl.InvokeRequiredbefore calling Invoke.BeginInvokeis the Asynchronous version ofInvoke. Asynchronous means the thread will not block the caller as opposed to a synchronous call which is blocking.