nan*_*ano 5 c# linq expression func
我想创建一个在后台线程中运行另一个方法的方法.像这样的东西:
void Method1(string param)
{
// Some Code
}
void Method2(string param)
{
// Some Code
}
void RunInThread(AMethod m)
{
//Run the method in a background thread
}
Run Code Online (Sandbox Code Playgroud)
如果您的方法具有返回值,请使用Func委托,否则您可以使用Action委托.例如:
void Method1(string param)
{
// Some Code
}
void Method2(string param)
{
// Some Code
}
void RunInThread(Action<string> m)
{
//Run the method in a background thread
}
Run Code Online (Sandbox Code Playgroud)
然后你可以这样打电话RunInThread:
RunInThread(Method1);
RunInThread(Method2);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
136 次 |
| 最近记录: |