Question: I am currently working on a c# project and I need to have a method which has 1 paramater to run as a thread. 

E.g. 

```
    public void myMethod(string path)
    {
       int i = 0;
       while (i != 0)
       {
          Console.WriteLine("Number: " + i);
          i++;
       }
    }

```

How can I call the above method from another method, but running inside a thread.

Thanks for any help you can provide.

Answer: 
The simplest way is generally to use an anonymous method or lambda expression:

```
string path = ...;

Thread thread = new Thread(() => MyMethod(path));
thread.Start();

```

You *can* use a `ParameterizedThreadStart`, but I generally wouldn't.

Note that if you do it in a loop, you need to be aware of the normal ["closing over the loop variable"](http://blogs.msdn.com/b/ericlippert/archive/2009/11/12/closing-over-the-loop-variable-considered-harmful.aspx) hazard:

```
// Bad
foreach (string path in list)
{
    Thread thread = new Thread(() => MyMethod(path));
    thread.Start();
}

// Good
foreach (string path in list)
{
    string copy = path;
    Thread thread = new Thread(() => MyMethod(copy));
    thread.Start();
}

```
Simply wrap that method call in a method that takes no parameters, but which calls your method with the right parameter.

```
public void myWrappingMethod()
{
    myMethod(this.Path);
}

public void myMethod(string path)
{
    // ...
}

```

Or if you have lambdas available, simply use one of those (per Jon Skeet's answer).