首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

线程里怎么给函数传参和获得返回值

2012-04-04 
线程里如何给函数传参和获得返回值?class ss{....public string aa(string s,int i){.....}}主线程里:ss s

线程里如何给函数传参和获得返回值?
class ss
{
 ....
 public string aa(string s,int i)
 {
  .....
 }
}

主线程里:
ss s=new ss();
Thread t=new Thread(new ThreadStart(s.aa));

问下怎样在线程中给s里的aa函数传参和获得返回值?最好多给几种方法,多多益善,多谢!

[解决办法]

class ss
{
 ....
 public string _t;
 public int _i
 

 public void bb()
 {
aa(_t,_i)
 }
 public string aa(string s,int i)
 {
.....
 }
}

主线程里:
ss s=new ss();
s._t="tt";
s._i=12
Thread t=new Thread(new ThreadStart(bb));
t.IsBackground=true;
t.Start();
[解决办法]
public void ThreadMethod(Action<string> callback)

热点排行