Could SynchronizationContext be used not in WinForms/WPF application?
I'm writing a component that would be used in WinForms or WPF applications also could be used in W开发者_Go百科indows services or Unit tests. Is there a way to use SynchronizationContext component in non UI apps?
Any (host) application can make its own SynchronizationContext
class and call SynchronizationContext.SetSynchronizationContext
.
Alternatively, you could make a no-op SynchronizationContext
in your library, then use it whenever SynchronizationContext.Current
is null
.
The question talks about writing a custom SynchronizationContext.
精彩评论