论坛类网站开发报价,抖音代运营培训,深圳室内设计公司排行,网站建设与管理设计创建无参数线程是无法发去传递参数的#xff0c;需要把 《 thread.Start(“张三”); 》改为《 thread.Start(); 》 把参数去掉就可以了。 public RegisterWindow(){InitializeComponent();//无参数线程Thread thread new Thread(pageLoad);thread.IsBackground true;//thr… 创建无参数线程是无法发去传递参数的需要把 《 thread.Start(“张三”); 》改为《 thread.Start(); 》 把参数去掉就可以了。
public RegisterWindow(){InitializeComponent();//无参数线程Thread thread new Thread(pageLoad);thread.IsBackground true;//thread.Start(“张三”);thread.Start(); }public void pageLoad(){//要执行的代码}
创建有参数线程使用 ParameterizedThreadStart委托实现
public RegisterWindow(){InitializeComponent();//创建参数化线程Thread thread new Thread(new ParameterizedThreadStart(pageLoad));thread.IsBackground true;//可以传递任意类型的数据 例如intstringlistarray等thread.Start(“张三”);}/// summary/// 参数化线程方法/// /summary/// param nameo传递过来的参数会变成object类型的/parampublic void pageLoad(object o){//要执行的代码}