c# 4.0 - Task.wait in task array -


i need execute line completed after tasks completed.i thought task.waitall(tasks) take care after executing callback method completed line gets executed.is there way block main thread untill task aray completes it.

taskpprcessor.batchstart(definition)

public void batchstart(list<taskdefinition> definition)         {             int = 0;             tasks = new task[definition.count];             definition.foreach((a) =>             {                  tasks[i] = task<taskresult>.factory.startnew(() => (taskresult)a.methodtocall.dynamicinvoke(a.arguments));                 tasks[i].continuewith(task => runtaskretobjresultins((task<taskresult>)task, a.completemethod));                     i++;              });             task.waitall(tasks); console.writeline("completed"); } 

i try this:

public void batchstart(list<taskdefinition> definition) {     task.waitall(         definition.select             (a => task<taskresult>.factory.startnew(                 () => (taskresult)a.methodtocall.dynamicinvoke(a.arguments)).continuewith(task => runtaskretobjresultins((task<taskresult>)task, a.completemethod))             ).toarray()         );     console.writeline("completed"); } 

i think problem continuewith returns new task, , that's 1 want wait for. you're waiting original tasks not continuation.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -