Hi,

I#ve got a prolem whith threads sharing Objects. The exception is "The calling thread cannot access the object because a different thread owns it".

My plan is to have a background thread that loads an image. As soon as it's loaded, I want the UI-Thread the display it.

Code:
Imports System.Windows.Media.Imaging

Public Class test
  Private m_Bitmap As BitmapImage

  Public ReadOnly Property Bitmap() As BitmapImage
    Get
      Return m_Bitmap
    End Get
  End Property


  Public Sub run()

    m_Bitmap = New BitmapImage(New Uri("C:\Users\shess\Pictures\unbenannt1.png"))

  End Sub
End Class


  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click

    Dim o As New test()
    Dim t As New System.Threading.Thread(AddressOf o.run)

    t.IsBackground = True
    t.Start()
    'o.run()   'THIS wors, bacause no second thread

    t.Join()

    Image1.Source = o.Bitmap 'THIS throws the error, because o.Bitmap was created in another thread

  End Sub

Help is very much appreciated!
SP