At the moment, I’ve got working:
public void logowanie()
{
int x=5,y=5;
...
}
private void button2_Click(object sender, EventArgs e)
{
Thread thread2 = new Thread(new ThreadStart(logowanie));
thread2.Start();
//logowanie("xd", "xd", "xd");
}
And that works. Is it possible to make something like
public int logowanie(int x, int y)
{
...
}
private void button2_Click(object sender, EventArgs e)
{
Thread thread2 = new Thread(new ThreadStart(logowanie(5,5)));
thread2.Start();
//logowanie("xd", "xd", "xd");
}
I’ve just started with threading things. Thanks
While you could use
ParameterizedThreadStart, I’d probably just use a lambda expression:Note that if you call this in a loop, you’ll need to be careful because of the way that variables are captured by lambda expressions:
This is only an issue in certain situations where you’re capturing a variable and really want to capture the current value instead, but it’s worth knowing about.