GVN said:
Hi All,
Can anyone guide me when asynchronous method calls will be
benificial? Are there any
disadvantages of using asynchronous calls?
There have been some replies that confuse multithreading with asynchronous
method calls. The two aren't the same. Threadpools and backgroundworker
threads are great but, they don't solve the same problems that async method
calls can solve.
Another reply gave an example of checking 1000 RSS feeds with a pool of 30
threads. The asynchronous approach would be to issue 1000 BeginRead() so
you have 1000 outstanding async calls then, as the reads complete, the
AsyncCallback method is called.
If you were writing a CHAT server, you could create a new thread for each
client but, that wouldn't scale very far. With an async approach, you would
call BeginRead() for each client then, when the read completes, the
AsyncCallback would call BeginWrite() for each client that the incoming
message should be directed to and then call BeginRead() again to replace the
read that just completed. This would scale to thousands of clients with
just a few threads.