日期:2014-05-18  浏览次数:20851 次

C#中以类的实例作为线程参数应该怎么操作
尝试过使用“ParameterizedThreadStart”以及“创建线程实现类”两种方式进行线程参数传递
string型参数可以正常传递
当传递类的实例时总是出问题,请指点一下应该怎样操作,给些方向性的建议也可以,谢谢!

------解决方案--------------------
C# code
private void Proc(object obj)
{
    List<int> list = (List<int>)obj;
}

// 线程调用

List<int> list = new List<int>();

Thread thread = new Thread(new ParameterizedThreadStart(Proc));
thread.Start(list);

------解决方案--------------------
探讨
引用:

C# code
private void Proc(object obj)
{
List<int> list = (List<int>)obj;
}

// 线程调用

List<int> list = new List<int>();

Thread thread = new Thread(new ParameterizedThreadStart……

------解决方案--------------------
探讨
引用:

C# code
private void Proc(object obj)
{
List<int> list = (List<int>)obj;
}

// 线程调用

List<int> list = new List<int>();

Thread thread = new Thread(new ParameterizedThreadStart……

------解决方案--------------------
探讨
引用:

引用:
引用:

C# code
private void Proc(object obj)
{
List<int> list = (List<int>)obj;
}

// 线程调用

List<int> list = new List<int>();

Thread thread = new Thread(……

------解决方案--------------------
C# code

//是这个意思吗?
void start()
{
   ThreadStart starter = delegate { dtChanger(dataset1); };//线程带参数
   new Thread(starter).Start();
}

void dtChanger(DataSet dataset1)
{
    //事件
}