Need some C# multithreading help..

Joined
Jan 10, 2007
Messages
43,898
Location
In The Machine
Here's some psuedo code...

int[] ids = new int[1000];
string[] names = new string[1000]

for (int i = 0 ; i < 1000 ; i++)
{
// open customer001txt through customer999.txt
// update the id and name array avariables
}

This is a VERY simplified version.. the real project consists of opening up hundereds of encrypted database files that must be decrypted, parsed, and then arrays in the parent class/thread need to be updated with info...

The problem is the single thread version now works fine, but takes forever.. most of the burden is decrypting and unpacking the database files.. if I could multi-thread this I could cut down processing time big time I believe..

Right now I am trying to use QueueUserWorkItem() and just load up all the file names using the object state var.. but because my worker function is static, I cant figure out how to update the arrays in the parent thread safely..

This seems like it would be a fairly common task.. use threads to pull a bunch of information from hundereds of files/databases and populate a parent table/structure with info...

I'm not looking to be spoon fed, just a little guidance.

Can anyone point me in the right direction?

Please help.

Thanks!

More...

View All Our Microsoft Related Feeds
 
Back
Top