Skip to content

Is it possible to build thread context/safety into UI controls—Invoke/BeginInvoke/Dispatch.Post/Send, etc. to remove boilerplate and so that we don't need to worry about SynchronizationContext(s)? #4656

Answered by weltkante
Shidell asked this question in Q&A
Discussion options

You must be logged in to vote

SynchronizationContext could potentially be eliminated (unless it has other duties I'm not currently familiar with)

You cannot eliminate that, it is the framework-independent API for doing thread switches, in e.g. libraries which aren't tied to WinForms only but can be used in any context. In fact much of the .NET runtime makes use of SynchronizationContext in this framework independent manner, in particular it is why when you await something you will continue on the right thread and don't have to worry about thread switches happening behind your back.

I feel like what I'm suggesting is too common-sense to not have been implemented a long time ago, and so I doubt the veracity of my cla…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Shidell
Comment options

@weltkante
Comment options

@Shidell
Comment options

@weltkante
Comment options

@Shidell
Comment options

Answer selected by RussKie
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants