Cross-thread call with WPF

Hi,

I'm trying to learn how to use Windows Presentation Foundation but I've got a really annoying problem.

I'm creating a multithread application in which one of the thread needs to change a textbox value in another form. But if I try to change it directly, an exception is raised (Cross-thread operation not valid: Control 'textBox1' accessed from a thread other than the thread it was created on).

That's why, beforce WPF, I was using the Invoke method, as explained here : http://msdn2.microsoft.com/en-us/library/ms171728.aspx

This worked just fine, but now problem is : I don't find any Invoke method in WPF controls, so I'm totally clueless. How am I supposed to make cross-thread calls

Thanks in advance.



Answer this question

Cross-thread call with WPF

  • Justin Merth

    Use the Invoke methods on the associated dispatcher:

    element.Dispatcher.Invoke...



  • Alisa619

    It works, thanks a lot :)
  • Cross-thread call with WPF