我有一个像这样的简单算法:
Parallel.ForEach(myList, new ParallelOptions() { MaxDegreeOfParallelism = 4 } ,(job) => job.doSomething());
Run Code Online (Sandbox Code Playgroud)
myList是一个List<MyType>.
MyType有void DoSomething()。
DoSomething我检查里面Thread.CurrentThread.IsThreadPoolThread。有些线程不是“ThreadPooled”;
c# multithreading threadpool task-parallel-library parallel.foreach