How to determine when all task is completed

后端 未结 4 1995
清歌不尽
清歌不尽 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:46

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

    Three options:

    • The blocking Task.WaitAll call, which only returns when all the given tasks have completed
    • The async Task.WhenAll call, which returns a task which completes when all the given tasks have completed. (Introduced in .NET 4.5.)
    • TaskFactory.ContinueWhenAll, which adds a continuation task which will run when all the given tasks have completed.

提交回复
热议问题