threading

  • Thread starter Thread starter Tony Johansson
  • Start date Start date
T

Tony Johansson

Hello!

I just wonder is it any point at all to use the ThreadStart delegete as I do
in example 1.
I mean I can just the same skip the ThredStart and add the method Foo as a
parameter directly as I do in example 2

1. private void button1_Click(object sender, EventArgs e)
{
ThreadStart start = new ThreadStart(Foo);
Thread myThread = new Thread(start);
myThread.Start();
}

2. private void button1_Click(object sender, EventArgs e)
{
Thread myThread = new Thread(Foo);
myThread.Start();
}

private void Foo()
{
MessageBox.Show("Thread running");
}

//Tony
 
I just wonder is it any point at all to use the ThreadStart delegete as I do
in example 1.
I mean I can just the same skip the ThredStart and add the method Foo as a
parameter directly as I do in example 2

1. private void button1_Click(object sender, EventArgs e)
{
ThreadStart start = new ThreadStart(Foo);
Thread myThread = new Thread(start);
myThread.Start();
}

2. private void button1_Click(object sender, EventArgs e)
{
Thread myThread = new Thread(Foo);
myThread.Start();
}

private void Foo()
{
MessageBox.Show("Thread running");
}

No need for ThreadStart with newer .NET versions.

It is required for some older versions.

Arne
 
No need for ThreadStart with newer .NET versions.

It is required for some older versions.

And older may be pretty old - I think 1.1!

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top