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

前端 未结 5 1011
暖寄归人
暖寄归人 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 09:48

    If you are using .Net 4.0 then you can use the Parallel.Invoke method like so

    Parallel.Invoke(()=> {
        // What ever code you add here will get threaded.
    });
    

    for more info see http://msdn.microsoft.com/en-us/library/dd992634.aspx

提交回复
热议问题