How Do I correct Thread Program?
-
Hi All, I need to run 3 methods parallaly.Then I have used Threading for that. Here is the code. public void threadtest() { Thread SpecialThread = new Thread(new ThreadStart(this.GetSpecial)); Thread BulkThread = new Thread(new ThreadStart(this.GetBulk)); Thread NormalThread = new Thread(new ThreadStart(this.GetNormal)); SpecialThread.Start(); BulkThread.Start(); NormalThread.Start(); SpecialThread.Join(); BulkThread.Join(); NormalThread.Join(); while((NormalThread.ThreadState==System.Threading.ThreadState.Running) || (BulkThread.ThreadState==System.Threading.ThreadState.Running) || (SpecialThread.ThreadState==System.Threading.ThreadState.Running) ) { } } But most of time one or two threads are going to aborted or something happen and I loose their results.Sometimes this worked properly and I can get all results from 3 methods. Can any one correct this code?
-
Hi All, I need to run 3 methods parallaly.Then I have used Threading for that. Here is the code. public void threadtest() { Thread SpecialThread = new Thread(new ThreadStart(this.GetSpecial)); Thread BulkThread = new Thread(new ThreadStart(this.GetBulk)); Thread NormalThread = new Thread(new ThreadStart(this.GetNormal)); SpecialThread.Start(); BulkThread.Start(); NormalThread.Start(); SpecialThread.Join(); BulkThread.Join(); NormalThread.Join(); while((NormalThread.ThreadState==System.Threading.ThreadState.Running) || (BulkThread.ThreadState==System.Threading.ThreadState.Running) || (SpecialThread.ThreadState==System.Threading.ThreadState.Running) ) { } } But most of time one or two threads are going to aborted or something happen and I loose their results.Sometimes this worked properly and I can get all results from 3 methods. Can any one correct this code?
dude! please get in the habbit of using pre and code tags for code in your posts, its hard to read if you dont
Harvey Saayman - South Africa Junior Developer .Net, C#, SQL think BIG and kick ASS
If (Programming != Your Passion)
{
you.suck = true;
}
else
{
you.suck = false;
}