Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What all is stored when we say synchronization context is stored?

When await is encountered, the control passes to the caller while awaited call waits for response.

Before control is passed to caller, the synchronization context is stored.

In case of windows app the synchronization context is the main UI thread. Thus when the await is complete, the saved context is restored and the rest of the code below the await executes with the original synchronization context.

I want to ask- what all items are stored in the synchronization context. For example:

  1. Current thread

  2. Local variable values

  3. What else?

like image 222
variable Avatar asked Oct 26 '25 14:10

variable


1 Answers

There is nothing stored in the SynchronizationContext. The SynchronizationContext is itself captured and stored by the asynchronous state machine, and used at the right moment by invoking its Post method. The local state is stored in the asynchronous state machine, along with the captured context.

like image 85
Theodor Zoulias Avatar answered Oct 29 '25 03:10

Theodor Zoulias