دوستان برای بخش dowork بک گراند ورکر این مدلی کد زدم
Invoke(new MethodInvoker(
delegate
{
//set the DataGridView control's data source
dataGridView1.DataSource = ds.Tables[0];
}));
حالا خواستم بدونم MethodInvoker با new Action(() چه فرقی داره کدام بهتر هست و امکان ایجاد خطارو کمتر میکنه
مثلا یجا بعد از fill کردن دیتاگرید خواستم ی لیبل مقدار بدم اینجوری زدم
label1.Invoke(new Action(() => label1.Text = @"TimeLoad: " + sw.Elapsed.ToString()));
The delegate can be an instance of EventHandler, in which case the sender parameter will contain this control, and the event parameter will contain EventArgs.Empty. The delegate can also be an instance of MethodInvoker, or any other delegate that takes a void parameter list. A call to an EventHandler or MethodInvoker delegate will be faster than a call to another type of delegate.
MethodInvoker provides a simple delegate that is used to invoke a method with a void parameter list. This delegate can be used when making calls to a control's Invoke method, or when you need a simple delegate but do not want to define one yourself.
an Action on the other hand can take up to 4 parameters.
But I don't think there is any difference between MethodInvoker and Action as they both simply encapsulate a delegate that doesn't take a paremter and returns void
این رو از نت گرفتم ولی خب زیاد متوجه نشدم دقیقا درکش نکردم ممنون میشم دوستان راهنمایی کنید