Hi Everyone,
I have a requirement to process a huge number of data from a database. Currently we designed a multi-threaded architecture which will make use of the ThreadPool class and we are using ThreadPool.QueueUserWorkItem method to add the processing request to the queue so that the free thread from the ThreadPool will pick the same for processing.
I am thinking of another way to implement the same. I am planning to use Asynchronous Method calls. I’m planning to call the method which will do the processing asynchronously using BeginInvoke and EndInvoke methrods. I’m planning to call EndInvoke method using a delegate.
Please advise me with the best approach.
Thanks,
Praveen KPosted Apr 24, 2008, 2:26 PM
Thanks a lot ashish. Actually I got the idea of asynchronous method invocation from the same MSDN URL only. What I need to know is how effective it is while comparing to the first approach that I specified. Anyways, I'm also thinking the asynchronous call will improve the performance. But as far as I know, the first approach that I mentioned is also a kind of Asynchronous Invocation only as the worker thread will just assign the work to a free thread in the ThreadPool. Please give your suggessions.
I read another article which says about the Observer Pattern, which can also be used for processing huge chunk of data parallelly. It will be really helpful if anyone can suggest which one of these is the best one to follow.
Why I am trying to get out of the simple multithreaded architecture is because of the high CPU usage. Any suggessions in this front is always welcome....
Thanks in advance,
AshishPosted Apr 24, 2008, 5:08 AM
Hi,
I hope below mentioned url will help u.
http://msdn2.microsoft.com/en-us/library/2e08f6yc(VS.80).aspx
FYI,
If u use BeginEnvoke and EndEnvoke methods of delegate then delegate is scheduled to be executed on the other thread. However current thread will continue with other operations. so that might cause the problem, just take care of that.
ASynchronous call will definately improve u r code performance....