Updating ObservableCollection from non UI thread

前端 未结 2 1860
失恋的感觉
失恋的感觉 2021-01-22 21:13

I am working on a Windows 8 Store app. I have a timer that calls a delegate every two minutes and makes an async web request. The resulting data is added to an observablecollect

相关标签:
2条回答
  • 2021-01-22 21:37

    It's usually easier to have the UI thread call background operations rather than having the background operations update the UI thread.

    So, I recommend you use DispatcherTimer, and then you won't need to use Dispatcher at all.

    0 讨论(0)
  • 2021-01-22 21:47

    Try using

    Deployment.Current.Dispatcher.BeginInvoke
    

    or

    Application.Current.Dispatcher.BeginInvoke
    
    0 讨论(0)
提交回复
热议问题