簡體   English   中英

如何使用私有或公共功能多線程? C#4.0

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

我如何多線程,以便它將在當前類或不同類中運行私有或公共功能?

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());

您可以在自己喜歡的任何地方將此上下文置於私有或公共方法中。 並且執行上下文也可以是私有的和公共的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM