0

I had a cool idea concerning threading in C#. I was reading a book called "CLR via C#" and it was discussing threading, and how people should seldom use actual thread objects, and instead should use the thread pooling services. The reason being they spool up worker threads for you to use and they reduce the overall overhead because of thread re-use. Now I had an idea. Since C# has now been open sourced and dumped online, I was thinking that perhaps an alteration to the threading API could allow us all to use the thread pool service behind the schenes without any extra effort on our part. All that would be required would be defining an 'internal' thread object for use in the API, and also defining an external thread object that is basically just a wrapper for a call to the thread pool service. Thread.Run would essentially call a thread pool. It seems like it would be easy peasy, but I thought I would leave it up to somebody who knows the API if they thought it was a good idea. The idea is kind of deceptive to the end programmer however, so it is up for debate.

2
Contributors
1
Reply
13
Views
3 Weeks
Discussion Span
Last Post by rproffitt
0

In a system I used I needed to maximise use of the CPU cores and thread so I used another method. I shared this in a discussion here: https://www.daniweb.com/programming/software-development/threads/496779/multi-threading-task-takes-much-longer-than-1-thread

I used this method because I found the method noted in the discussion to pile up on one core. After my change I've seen my system updating 16 devices over RS232 (this is an industrial app) and without the usual delays.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.