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

ConfigureAwait behavior in C Sharp (C#) - Interactive Code Practice

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

Complete the code to await the task without capturing the current synchronization context.

C Sharp (C#)
await someTask.[1](false);
Drag options to blanks, or click blank then click option'
AWait
BConfigureAwait
CGetAwaiter
DContinueWith
Attempts:
3 left
💡 Hint
Common Mistakes
Using ContinueWith instead of ConfigureAwait.
Forgetting to call ConfigureAwait at all.
Using GetAwaiter which does not take parameters.
2fill in blank
medium

Complete the code to resume on the original synchronization context after awaiting.

C Sharp (C#)
await someTask.[1](true);
Drag options to blanks, or click blank then click option'
AGetAwaiter
BContinueWith
CConfigureAwait
DWait
Attempts:
3 left
💡 Hint
Common Mistakes
Passing false when the goal is to resume on the original context.
Using ContinueWith which does not guarantee context capture.
3fill in blank
hard

Complete the code to await the task without capturing the current synchronization context.

C Sharp (C#)
var result = await someTask.[1];
Drag options to blanks, or click blank then click option'
AConfigureAwait
BConfigureAwait(true)
CGetAwaiter().GetResult()
DConfigureAwait(false)
Attempts:
3 left
💡 Hint
Common Mistakes
Using just ConfigureAwait without the parameter.
Using ConfigureAwait(true) which captures the context.
Using blocking calls like GetAwaiter().GetResult() which can deadlock.
4fill in blank
hard

Fill both blanks to create a task that does not capture the synchronization context and returns a string result.

C Sharp (C#)
async Task<string> GetDataAsync() {
    var data = await FetchDataAsync().[1]([2]);
    return data;
}
Drag options to blanks, or click blank then click option'
AConfigureAwait
Bfalse
Ctrue
DGetAwaiter
Attempts:
3 left
💡 Hint
Common Mistakes
Passing true instead of false.
Using GetAwaiter which does not take parameters.
5fill in blank
hard

Fill both blanks to create a dictionary comprehension that stores task results without capturing the synchronization context.

C Sharp (C#)
var results = new Dictionary<int, string>();
foreach (var id in ids) {
    results[id] = await GetDataAsync(id).[1]([2]);
}
Drag options to blanks, or click blank then click option'
AConfigureAwait
Bfalse
DConfigureAwait(false)
Attempts:
3 left
💡 Hint
Common Mistakes
Putting ConfigureAwait(false) as one option (not allowed here).
Adding extra characters in the third blank.