8

First way:

var tds=SearchProcess();
await tds;

public async  Task<XmlElement> SearchProcess()
{
}

Second way:

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

public XmlElement SearchProcess()
{
}

In above both approach any performance difference is there?

2

1 Answer 1

8

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    
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.