开发者

How do I multi-thread with private or public functions? C# 4.0

How do I multi-thread so that it will run private or public functions in the current class or di开发者_运维知识库fferent classes?


List<Action> tasks = new List<Action>();

tasks.Add(() => { ... do whatever });
tasks.Add(() => { ... do whatever });
tasks.Add(() => { ... do whatever });
tasks.Add(() => { ... do whatever });

System.Threading.Tasks.Parallel.Invoke(tasks.ToArray());

u can put this context in private or public method anywhere u like. and the execution context can also be both private and public.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜