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

How async execution flows in C Sharp (C#) - Quick Revision & Summary

Choose your learning style9 modes available
Recall & Review
beginner
What does the 'async' keyword do in C#?
The 'async' keyword marks a method as asynchronous, allowing it to run operations without blocking the main thread and enabling the use of 'await' inside it.
Click to reveal answer
beginner
What is the role of the 'await' keyword in async methods?
'await' pauses the execution of the async method until the awaited task completes, then resumes execution without blocking the thread.
Click to reveal answer
beginner
How does async execution flow affect the main thread?
Async execution allows the main thread to continue running other code while waiting for asynchronous operations to complete, improving responsiveness.
Click to reveal answer
intermediate
What happens when an async method reaches an 'await' statement?
When an async method reaches 'await', it returns control to the caller and schedules the rest of the method to continue after the awaited task finishes.
Click to reveal answer
beginner
Explain the difference between synchronous and asynchronous execution flow.
Synchronous execution runs tasks one after another, blocking the thread until each finishes. Asynchronous execution allows tasks to run without blocking, letting the program do other work while waiting.
Click to reveal answer
What does the 'async' keyword enable in a C# method?
AAllows the method to run without blocking and use 'await'
BMakes the method run faster synchronously
CPrevents the method from returning a value
DDisables exception handling inside the method
What happens when 'await' is used on a Task in an async method?
AThe method pauses and the thread is blocked
BThe method runs synchronously without pausing
CThe method pauses but the thread is free to do other work
DThe method throws an exception immediately
Which statement best describes async execution flow?
ATasks run one after another, blocking the thread
BTasks run without blocking, allowing other code to run
CTasks run only on background threads
DTasks run only after the main thread finishes
When an async method hits an 'await', what does it do?
AThrows a runtime error
BBlocks the thread until the task completes
CImmediately completes the method
DReturns control to the caller and resumes later
Why is async execution useful in UI applications?
AIt keeps the UI responsive during long operations
BIt makes the UI freeze while waiting
CIt disables user input
DIt slows down the application
Describe how the flow of execution changes when using async and await in C#.
Think about what happens when the method reaches 'await' and how the thread behaves.
You got /5 concepts.
    Explain why async execution improves application responsiveness, especially in UI apps.
    Consider what happens if the main thread is blocked during a long task.
    You got /4 concepts.