Multi-threading libraries for .NET

后端 未结 10 1740
挽巷
挽巷 2021-02-14 08:28

I used multiple threads in a few programs, but still don\'t feel very comfortable about it.

What multi-threading libraries for C#/.NET are out there and which advantages

10条回答
  •  抹茶落季
    2021-02-14 09:05

    Please keep in mind that you really should be closing threads (or allowing the threadpool to dispose) when you no longer need them, unless you will need them again soon. The reason I say this is that each thread requires stack memory (usually 1mb), so when you have applications sitting on threads but not using them, you are wasting memory.

    For exmaple, Outlook on my machine right now has 20 threads open and is using 0% CPU. That is simply a waste of (a least) 20mb of memory. Word is also using another 10 threads with 0% CPU. 30mb may not seem like much, but what if every application was wasting 10-20 threads?

    Again, if you need access to a threadpool on a regular basis then you don't need to close it (creating/destroying threads has an overhead).

提交回复
热议问题