c#多线程方法名称

Sha*_*e.C 2 c# methods multithreading

我正在尝试创建一个循环,为列表中的每个程序创建一个线程,但我在下面的代码上传递周长时得到"预期的方法名称"错误;

for (i = 0; i <= programs.Count; i++)
{
    checkProcess check = new checkProcess();
    // check.isRunning();

    string filename = programs[i].Filename;
    string filepath = programs[i].Filepath;

    mWorkerThread = new Thread(new ThreadStart(check.isRunning(filename, filepath)));

    mWorkerThread.Start();
}
Run Code Online (Sandbox Code Playgroud)

我读了一些代表,但似乎无法让他们在我的问题的背景下工作.任何帮助将非常感谢我应该朝哪个方向前进.

Mat*_*ten 12

线程目标应该是可执行的,而不是您的方法的结果.

mWorkerThread = new Thread(new ThreadStart(check.isRunning(filename, filepath)));
Run Code Online (Sandbox Code Playgroud)

在你的情况上面,您尝试创建的新实例ThreadStart返回值check.IsRunning(...).你想要的是什么

mWorkerThread = new Thread( () => check.isRunning(filename, filepath) );
Run Code Online (Sandbox Code Playgroud)