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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -