; :
static ThreadStart CurryForFun(int i, int j)
{
return () => Fun1(i, j);
}
Thread FirstThread = new Thread(CurryForFun(5, 12));
or write your own capture type (this is generally comparable to what the compiler does for you when you use the anon methods / lambdas with the captured variables, but are implemented differently):
class MyCaptureClass
{
private readonly int i, j;
int? result;
public int Result { get { return result.Value; } }
public MyCaptureClass(int i, int j)
{
this.i = i;
this.j = j;
}
public void Invoke()
{
result = Fun1(i, j);
}
}
...
MyCaptureClass capture = new MyCaptureClass(5, 12);
Thread FirstThread = new Thread(capture.Invoke);
source
share