use*_*973 1 c# multithreading delegates
我只是一个初学者."ParameterizedThreadStart"接受单个对象作为参数.
有没有其他代表签名允许我
(1)在线程上传递params(变量参数)?
(2)支持列表等通用参数?
您可以使用单个对象执行任何操作.只需定义一个类来包装您感兴趣的参数:
class ThreadState
{
public ThreadState()
{
}
public string Name
{
get;
set;
}
public int Age
{
get;
set;
}
}
// ...
ParameterizedThreadStart start = delegate(object objThreadState)
{
// cast to your actual object type
ThreadState state = (ThreadState)objThreadState;
// ... now do anything you want with it ...
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
97 次 |
| 最近记录: |