小编Lui*_*ues的帖子

Parallel.ForEach<T> 的某些项目在 ThreadPool 上运行,有些则不在

我有一个像这样的简单算法:

Parallel.ForEach(myList, new ParallelOptions() { MaxDegreeOfParallelism = 4 } ,(job) => job.doSomething());  
Run Code Online (Sandbox Code Playgroud)

myList是一个List<MyType>.

MyTypevoid DoSomething()

DoSomething我检查里面Thread.CurrentThread.IsThreadPoolThread。有些线程不是“ThreadPooled”;

c# multithreading threadpool task-parallel-library parallel.foreach

3
推荐指数
1
解决办法
74
查看次数