multithreading - Thread execution order in c# -
i have list of thread want ensure execution order between them code
for (int k = 0; k < radiolist.count; k++) { (int = 0; < filepaths.count(); i++) { thread t = new thread(delegate() { thread_encde_function(tempradio.publishpoint, filepaths[i], encodingtype); }); t.start(); thread.sleep(1000); } }
i want know if thread.join()
can job.
if tasks can execute asynchronously (out of order), threads appropriate. however, if have number of tasks want execute in order (strictly 1 after other), why use threads? should execute them in loop, can't parallelized. using thread.join
wait thread right after start trick, way have wait until task finished before starting next one, executing them in order.
however, if have parts of tasks can executed simultaneously, , other parts have sequential, can take @ c# task parallel library, makes doing things easy.
Comments
Post a Comment