How to determine when all task is completed

后端 未结 4 1993
清歌不尽
清歌不尽 2021-02-14 11:50

here is sample code for starting multiple task

Task.Factory.StartNew(() =>
        {
            //foreach (KeyValuePair entry in dicLis         


        
4条回答
  •  粉色の甜心
    2021-02-14 12:28

    if i start 10 task using Task.Factory.StartNew() so how do i notify after when 10 task will be finish

    You can use Task.WaitAll. This call will block current thread until all tasks are finished.

    Side note: you seem to be using Task, Parallel and Thread.SpinWait, which makes your code complex. I would spend a bit of time analysing if that complexity is really necessary.

提交回复
热议问题