title: How to Wait until all Items processed in a list using Async Await - c#
body: <p>I am trying to achieve following functionality using this code</p>
  
  <p><strong>1.</strong> I have list of items and i want process items in parallel way to speed up    the process.</p>
  
  <p><strong>2.</strong> Also i want to wait until all the data in the list get processed and same thing i need to update in database</p>
  
  <pre><code>   private async Task&lt;bool&gt; ProceeData&lt;T&gt;(IList&lt;T&gt; items,int typeId,Func&lt;T, bool&gt; updateRequestCheckPredicate, Func&lt;T, bool&gt; newRequestCheckPredicate)
      {
              continueFlag = (scripts.Count &gt; =12 ) ? true : false;
              await ProcessItems(items, updateRequestCheckPredicate, newRequestCheckPredicate);
  
              //Wait Until all items get processed and Update Status in database
  
              var updateStatus =UpdateStatus(typeId,DateTime.Now);
               return continueFlag;
      }
  
      private async Task ProcessItems&lt;T&gt;(IList&lt;T&gt; items,Func&lt;T, bool&gt; updateRequestCheckPredicate, Func&lt;T, bool&gt; newRequestCheckPredicate)
      {
         var itemsToCreate = items.Where(newRequestCheckPredicate).ToList();
  
          var createTask  = scripts
                       .AsParallel().Select(item =&gt; CrateItem(item);
                       .ToArray();
          var createTaskComplete = await Task.WhenAll(createTask);
  
          var itemsToUpdate = items.Where(updateRequestCheckPredicate).ToList();
  
          var updateTask = scripts
                     .AsParallel().Select(item =&gt; UpdateItem(item)
                     .ToArray();
  
          var updateTaskComplete = await Task.WhenAll(updateTask);
      }
  
       private async Task&lt;ResponseResult&gt; CrateItem&lt;T&gt;(T item)
      {
          var response = new ResponseResult();
           Guid requestGuid = Guid.NewGuid();
          auditSave = SaveAuditData(requestGuid);
          if (auditSaveInfo.IsUpdate)
          {
             response = await UpdateItem(item);
          }
          response = await CreateTicket&lt;T&gt;(item);
          // Wait response
          UpdateAuditData(response)
      }
      private async Task&lt;ServiceNowResponseResult&gt; CreateTicket&lt;T&gt;(T item)
      {
          // Rest call and need to wait for result
          var response = await CreateNewTicket&lt;T&gt;(scriptObj, serviceRequestInfo);
          return response;
      }
  </code></pre>
  
  <p>I am new to await async concept and so anyone pls advice me whether i am doing is a right approach or If wrong pls help me with help of a sample code</p>