Which code segment should you use?

You are developing an application that uses multiple asynchronous tasks to optimize
performance.
You need to retrieve the result of an asynchronous task.
Which code segment should you use?

You are developing an application that uses multiple asynchronous tasks to optimize
performance.
You need to retrieve the result of an asynchronous task.
Which code segment should you use?

A.
Option A

B.
Option B

C.
Option C

D.
Option D



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Mah

Mah

A should be correct. In C public async Task GetData() wrong

Nick

Nick

Correct answer is C.
Answer A will cause error because of missing async

j

j

protected async void StartTAsk()
{
string result = await GetData();
}

public async Task GetData()
{
string result = “”;
await Task.Run(()=>result=”ok”);
return result;
}

rao

rao

C seems to be correct

Lance

Lance

C is correct, question says “asynchronous task”