2

I am working on WPF with images. When calling an Image control to set the imageSource it is needed to use the dispatcher if image comes from different thread instead of the GUI thread.

I just wonder if I can set an ImageBrush instead to work multithreaded.

Regards

Nasenbaer
  • 4,810
  • 11
  • 53
  • 86

2 Answers2

2

No, it is not the image but the whole WPF framework that is not thread-safe.

So any manipulation to the GUI has to be from the main thread (Dispatched).

H H
  • 263,252
  • 30
  • 330
  • 514
  • Hi and thanks. Is dispatcher already needed when asking if object is available. Like this: ?`Windows1.LayoutRoot.Image1`Is Nothing` – Nasenbaer Jul 08 '11 at 08:50
  • @naseri : Just try it in debug mode, I would think reading is safe. – H H Jul 09 '11 at 09:49
1

If you call Freeze() on the ImageBrush, you can use it in multiple threads. You can only access the Image Control in the main thread though.

mdm20
  • 4,475
  • 2
  • 22
  • 24