Should I notice a difference in using Task vs Threads in .Net 4.0?

前端 未结 5 1009
暖寄归人
暖寄归人 2021-02-05 08:59

I updated my code to use Tasks instead of threads....

Looking at memory usage and CPU I do not notices any improvements on the multi-core PC, Is this expected?

M

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-05 10:00

    You would see difference if your original or converted code do not utlize CPU completely. I.e. if original code always limited number of threads to 2, on quad-core machine it will run at about 50% load with manually created threads and potentially 100% load with tasks (if your tasks can be actaully paralellized). So it looks like either your original code was reasonable from performance point of view, or both implemetaion suffer issues showing similar underutiliztion of CPU.

提交回复
热议问题