Quantcast
Viewing all articles
Browse latest Browse all 764

Async Execution - ThreadPools, BackgroundWorker??

Guys, hope eveyone is well, but need some advice.

I have a class, and that class has children.  Each child is going to connect to a database, calculate some values and return.  At the moment this run in sync, so i loop through each child, connect to database, get result and move on to the next one.

This works fine, but i think running the code in async mode would benefit performance.

I seen this on microsoft site http://msdn.microsoft.com/en-us/library/3dasc8as(v=vs.80).aspx describing how to use a ThreadPool to execute async tasks, and the code waits until all the tasks are finished.  This sounds exactly like what i want to do, but i understand the Prinical objects etc are not copied over into other threads? I am using asp.net 4.0.

I havent done much async processing, and none where i need to carry the current prinical object.

I have seen that Csla has a backgroundWorker which does pass on the prinicipal values etc.  Is there a limit on the number of BackgroundWorkers i can create?  How would i wait for all backgroundworkers to complete?

Sorry i this is basic, but thought i would ask here as maybe someone else has had this problem as well


Viewing all articles
Browse latest Browse all 764

Trending Articles