Use of SynchronizationContext question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • schaf

    Use of SynchronizationContext question

    Hi All!
    I have a little question about the Synchronization Context. i'm using
    it for UI synchronization .
    Is it better the synchronize to the main thread (UI thread) as soon as
    the event (thread pool thread) is handled or just for the functions,
    which really access the UI?

    In my application I handle events (thread pool threads) in a common
    library (lib1). lib1 will fire an event for all interested objects
    (which are registered as event listnerer in lib1). Some of these
    objects will access the UI to do some wotk, others will just doing
    business logic.

    So now I can synchronize to the main thread in lib1, or just in the
    corresponding objects, which access the UI. What is the pro and contra
    of these two possibilities? what is recommended?

    Thanks and Regards
    Marcel
  • Marc Gravell

    #2
    Re: Use of Synchronization Context question

    It depends how complex the UI is ;-p

    It is very rare that I have used sync-context to switch threads at the
    library level; on one occasion this was because data-binding only
    expected events on the UI thread, and couldn't be intercepted - see:


    On most occasions I'd let each local handler worry about it

    Marc

    Comment

    Working...