Reputation: 13
I am reading conflicting opinions here. Am I right that although an asynchronous method call also gets handled by a thread pool invisible to the user, this is likely to save resources because the underlying operating system is able to suspend these threads whilst IO calls are pending ?
Upvotes: 1
Views: 315
Reputation: 24847
'an asynchronous method call also gets handled by a thread pool invisible to the user' - yes, something must do the I/O!
'this is likely to save resources because the underlying operating system is able to suspend these threads whilst IO calls are pending' - the OS is able to suspend user threads while I/O is pending as well.
In high-performance apps, asynchronous wins because more work is pushed into the kernel where better thread management is possible. This does reduce context switches and also avoids a lot of data copying.
Upvotes: 0
Reputation: 20620
Ideally, if possible, you would use .net 4.0 System.Threading.Tasks.Parallel class. It will take advantage of multi-core processors.
And it's simple.
Upvotes: 0
Reputation: 2266
You are exactly right. The IO threads are not only suspended, they are retired when they become unneeded. But async IO is not a general solution for all problems and here is why:
Upvotes: 1