0
0
C Sharp (C#)programming~10 mins

Why async programming is needed in C Sharp (C#) - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start an asynchronous task.

C Sharp (C#)
Task.Run(() => [1]);
Drag options to blanks, or click blank then click option'
ADoWork()
Bawait DoWork()
CDoWork
Dasync DoWork()
Attempts:
3 left
💡 Hint
Common Mistakes
Using await inside Task.Run without async lambda.
Passing method name without parentheses.
2fill in blank
medium

Complete the code to await an asynchronous method.

C Sharp (C#)
await [1]();
Drag options to blanks, or click blank then click option'
ADoWork
BRunWork
CDoWorkAsync
DStartWork
Attempts:
3 left
💡 Hint
Common Mistakes
Awaiting a synchronous method.
Calling async method without await.
3fill in blank
hard

Fix the error in the async method declaration.

C Sharp (C#)
public async [1] DoWorkAsync() { await Task.Delay(1000); }
Drag options to blanks, or click blank then click option'
ATask
Bint
Cvoid
Dasync
Attempts:
3 left
💡 Hint
Common Mistakes
Using void as return type for async method.
Returning int from async method.
4fill in blank
hard

Fill both blanks to create a dictionary of tasks and await their completion.

C Sharp (C#)
var tasks = new Dictionary<string, Task> { {"task1", [1] }, {"task2", [2] } };
await Task.WhenAll(tasks.Values);
Drag options to blanks, or click blank then click option'
ADoWorkAsync()
BDoWork()
CRunAsync()
DRun()
Attempts:
3 left
💡 Hint
Common Mistakes
Using synchronous methods in the dictionary.
Not awaiting Task.WhenAll.
5fill in blank
hard

Fill all three blanks to create an async method that returns a string after delay.

C Sharp (C#)
public async Task<string> [1]() {
    await Task.Delay([2]);
    return [3];
}
Drag options to blanks, or click blank then click option'
AGetDataAsync
B1000
C"Done"
DFetchData
Attempts:
3 left
💡 Hint
Common Mistakes
Using synchronous method name.
Returning a non-string value.
Incorrect delay time format.