OK so I am trying to speed a program by using mutli threading. I have used it before successfully but never in a loop. I think its pretty easy to follow my code. The problem is the 2nd time i run the thread it says "terminated or already running" ... but that makes no sense. I have tried to use a join (wait till it finishes), or abort(stop it) but neither work.
If you curious, i am doing this because the calculation takes longer than it does to pull the data, however pulling the data does take a few seconds, so this way, i am only waitting for the AddNum function on no the pull or insert. (I am pulling data from SQL and doing some stuff and putting it back in SQL)
Everything is defined correctly as threads, everything works perfect, until i put the loop on.
If you curious, i am doing this because the calculation takes longer than it does to pull the data, however pulling the data does take a few seconds, so this way, i am only waitting for the AddNum function on no the pull or insert. (I am pulling data from SQL and doing some stuff and putting it back in SQL)
Everything is defined correctly as threads, everything works perfect, until i put the loop on.
Code:
Do While Place <= 40100
Prime = PrePrime
Power = PrePower
UpdateFactorThread.join()
AddNumThread.Start()
Place = Place + count
count = count + 1
GetInfoThread.Start()
GetInfoThread.Join()
AddNumThread.Join()
AddNumThread.Suspend()
Place = Place - 1
UpdateFactorThread.Start()
Loop
Comment