我从旧帖子中获得了此代码
public delegate void Worker();
private static Thread worker;
public static void Init(Worker work)
{
worker = new Thread(new ThreadStart(work));
worker.Start();
}
public static void Work()
{
string result = testing;
}
我通过添加参数来修改代码,当我尝试调用 Init("AA") 时出现错误“最佳重载方法有一些无效参数”
以下是编辑后的代码
public delegate void Worker();
private static Thread worker;
public static void Init(Worker work)
{
worker = new Thread(new ThreadStart(work));
worker.Start();
}
public static void Work(string testing)
{
string result = testing;
}