如何用带字符串的函数调用线程? C#

我试过了:

Thread uiThread = new Thread(new ParameterizedThreadStart(Loading));
uiThread.Start("hey");

调用函数

public void Loading(string state)

但是我得到了匹配的委托'System.Threading.ParameterizedThreadStart'

我需要做些什么?

评论
  • qodio
    qodio 回复

    ParameterizedThreadStart takes an object instead of string. You will just have to cast it.

    public void Loading(object state)
    {
       string stateString = state as string;