Home > DeveloperSection > Forums > Difference between await and Task.Wait
Tanuj Kumar

Total Post:134

Posted on    December-27-2013 6:49 AM

 C# C# 

 1 Reply(s)
 3420  View(s)
Rate this:

First way:

var tds=SearchProcess();

await tds;

public async  Task<XmlElement> SearchProcess()



Second way:

var tds= Task.Factory.StartNew(()=>SearchProcess());


public XmlElement SearchProcess()



In above both approach any performance difference is there?

Alex Leblois
Alex Leblois

Total Post:67

Posted on    December-27-2013 7:39 AM

Hi Tanuj,

Task.WaitAll is blocking, while using await will make the containing method async. To wait for multiple tasks asynchronously you can use Task.WhenAll:

public async Task DoSomething()


    IEnumerable<Task> tds = SearchProcess();

    await Task.WhenAll(tds);

    //continue processing   


Don't want to miss updates? Please click the below button!

Follow MindStick