المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Multiple Thread not running at same time



C# Programming
08-26-2009, 09:45 AM
Dear All,
i have following code to run 34 activities at same time, but it seems it doesent.
foreach(ListViewItem prv in des.lProvinces.CheckedItems)
{
if (prv.Text.Equals("All"))
continue;
pmuAccessPath=string.Format("{0}\\{1}\\NSPDatabase.mdb",des.DestinationFolder,prv.Text.Trim());
if (!Directory.Exists(Path.GetDirectoryName(pmuAccessPath)))
Directory.CreateDirectory(Path.GetDirectoryName(pmuAccessPath));
if (!File.Exists(pmuAccessPath))
File.Copy(des.SourceAccessPath,pmuAccessPath);
Finish fin=new Finish();
pnlControls.Controls.Add(fin);
fin.Dock=DockStyle.Top;
fin.lblProvince.Text=string.Format("Province : ({0})",prv.Text);
fin.lblProvince.*******();
Triplet triplet=new Triplet(fin,pmuAccessPath,prv.Tag);
ThreadPool.QueueUserWorkItem(new WaitCallback(runMultiple),(object)triplet);
Thread.Sleep(50);
}

the method runMultiple, queries some tables from sql server 2005 and then inserts those into Access Database.
count of items is 34, for the first time it performs all but then it stops and executes only one by one.
like one gets finished and another starts.
i want to all should run at same time?

Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan