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

How async execution flows in C Sharp (C#) - Interactive Practice

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

Complete the code to declare an asynchronous method.

C Sharp (C#)
public async Task [1]() {
    await Task.Delay(1000);
}
Drag options to blanks, or click blank then click option'
AFetchData
BRun
CExecuteAsync
DDoWork
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names without 'Async' suffix for async methods.
2fill in blank
medium

Complete the code to await an asynchronous method call.

C Sharp (C#)
await [1]();
Drag options to blanks, or click blank then click option'
AExecuteAsync
BRun
CDoWork
DFetchData
Attempts:
3 left
💡 Hint
Common Mistakes
Awaiting methods that are not asynchronous.
3fill in blank
hard

Fix the error in the async method by adding the missing keyword.

C Sharp (C#)
public [1] Task<int> GetNumberAsync() {
    return Task.FromResult(42);
}
Drag options to blanks, or click blank then click option'
Avoid
Bawait
Cstatic
Dasync
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the 'async' keyword on asynchronous methods.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that filters async tasks by completion status.

C Sharp (C#)
var completedTasks = tasks.Where(t => t.[1]).ToDictionary(t => t.Id, t => t.[2]);
Drag options to blanks, or click blank then click option'
AIsCompleted
BResult
CStatus
DStartTime
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Status' instead of 'IsCompleted' for filtering.
Using 'StartTime' instead of 'Result' for dictionary values.
5fill in blank
hard

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

C Sharp (C#)
public async Task<int> [1](string input) {
    await Task.[2](500);
    return input.[3];
}
Drag options to blanks, or click blank then click option'
AGetLengthAsync
BDelay
CLength
DWait
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Wait' instead of 'Delay' causes blocking instead of async wait.
Returning 'input.Length()' with parentheses causes error because Length is a property.