How to deal with cross-thread access exceptions?

后端 未结 3 1613
一个人的身影
一个人的身影 2020-11-22 10:23

A common exception one can get when working with multiple threads in WPF is:

The calling thread cannot access this object because a different thread o

3条回答
  •  囚心锁ツ
    2020-11-22 10:48

    That would be several hundred lines of code, for something I "figured out".

    But the summary is:

    App_OnStartup generate a background thread

    in the callback,

    Call

    Application.Current.MainWindow.Dispatcher.CheckAccess() - gets the exception Application.Current.Dispatcher.CheckAccess() does not

提交回复
热议问题