0

I have a problem with threads and dispatcher in wpf, I created a thread which in certain cases bind class(wpf page control) to Main.MainContent.Content, only works the first time, then it doesn't work. I am a beginner in this topic, so I am asking for understanding and a thorough explanation. Let me add that I read a bit about DispatcherPriority Enum and tried to replace BeginInvoke with Invoke.

problem preview 1

problem preview 2

Thomas Weller
  • 55,411
  • 20
  • 125
  • 222

1 Answers1

0

I solved my problem by changing one line:

MainWindow.Main.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { MainWindow.Main.MainContent.Content = new AcceptedPage(); }));

on:

Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { Application.Current.MainWindow.Content = new AcceptedPage(); }));