Here Is my Example
private void button1_Click(object sender, EventArgs e)
{
ThreadClass th = new ThreadClass();
th.ThreadMth(8, 10, (report) =>
{
this.Invoke(new Action(() =>
{
listBox1.Items.Add(report);
}));
});
}
}
public class ThreadClass
{
private delegate int myDelegate(int x, int y);
Action<int> myActionReport = (v1) => { };
public void ThreadMth(int xX, int yY, Action<int> actionReport)
{
myDelegate Sum = (x, y) =>
{
Thread.Sleep(5000);
return x + y;
};
Sum.BeginInvoke(xX, yY, result =>
{
myDelegate ss = (myDelegate)result.AsyncState;
actionReport((int)ss.EndInvoke(result));
}, Sum);
}
}
</int></int>
So, you build delegates and methods with same signature( point delegate to method). if you want new thread delegate.BeginInvoke;
I like to use Lambda, just like in code.
Sorry for my English (I am from Latvia)
good luck!
this is how I do.