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
8 Comments on “Which code segment should you use?”
PaulCsays:
C
0
0
Mahsays:
A should be correct. In C public async Task GetData() wrong
1
0
Nicksays:
Correct answer is C.
Answer A will cause error because of missing async
C
0
0
A should be correct. In C public async Task GetData() wrong
1
0
Correct answer is C.
Answer A will cause error because of missing async
0
1
No, it won’t 🙂 check in VS
0
0
protected async void StartTAsk()
{
string result = await GetData();
}
public async Task GetData()
{
string result = “”;
await Task.Run(()=>result=”ok”);
return result;
}
0
2
C seems to be correct
0
1
C is correct, question says “asynchronous task”
0
1
Task is already asynchronous, one more async/await is redundant. A and C works, but C contains redundant operators, so the correct answer is A
0
0