Reputation: 311
I understand what a synchronizationcontext is but I just don't understand what the "synchronization" in the word means. Do you have any ideas?
Thanks
Upvotes: 5
Views: 195
Reputation: 2668
Synchronization or better for your understanding lets first understand what word Synchronize means.
Don't go with the dictionary definition it will confuse you for now. Instead lets take an oversimplified analogy:
When we walk, our legs are synchronized! That is, they
coordinate/cooperate
together to complete an activity called walking. When left foot touches the ground the right foot leaves it (or is in process of leaving), and when right foot touches its vice-versa.The key takeaway is, both feet have an implicit coordination stating that other will start (i.e. leave ground) only when first one is grounded.
So talking in terms of Threads and shared resources. This same analogy applies. All the threads want to work with some shared resource (in our case ground). Thus they need to "coordinate" there usage of the resource.
So when you hear the word "Synchronization", think word coordinate/cooperate
. Hope you understand now. I'm purposefully not explaining SynchronizationContext
since you state you know it already.
Update: On second though, I should provide you some details here as well, in terms of the analogy:
Hopefully you now understand, what synchronization means! Talking in terms of SynchronizationContext
, it simply is a class that allows you to have synchronization (i.e. coordination/cooperation) with existing UI thread's resources (which are mostly UI components and there state). The way this is usually achieved is by putting messages into the UI thread's queue, instead of directly modifying the UI state yourself.
Disclaimer: Don't try the walking analogy yourself, I just lost 2 calories when trying to figure out my leg's synchronization
.
Upvotes: 4