Can anyone help me with this issue...
I'm trying to create a single window with multi threading for processing images.
If i launch a process.exe for each processing operation i do not get this problem....
Here is my function:
    private ImageSource ImageApplyEffect(ImageSource imageSource, Effect effect, Size size)
    {
        DrawingVisual d = new DrawingVisual();
        DrawingContext dc = d.RenderOpen();
        dc.DrawImage(imageSource, new Rect(new Point(0, 0), size));
        d.Effect = effect;
        dc.Close();
        dc = null;
        RenderTargetBitmap frameRenderTargetBitmap2 = new RenderTargetBitmap((int)size.Width,
                                                                             (int)size.Height,
                                                                              1 / 96,
                                                                              1 / 96,
                                                                              PixelFormats.Default);
        frameRenderTargetBitmap2.Render(d);
        d = null;
        BitmapFrame frameBitmapFrame2 = BitmapFrame.Create(frameRenderTargetBitmap2);
        frameRenderTargetBitmap2 = null;
        MemoryStream mStream = new MemoryStream();
        PngBitmapEncoder encoder = new PngBitmapEncoder();
        encoder.Frames.Add(frameBitmapFrame2);
        encoder.Save(mStream);
        BitmapImage bImg = new BitmapImage();
        bImg.BeginInit();
        bImg.StreamSource = mStream;
        bImg.EndInit();
        frameBitmapFrame2 = null;
        ImageSource imgS = bImg;
        encoder = null;
        return imgS;
    }
I get this exception:
The calling thread cannot access this object because a different thread owns it!
Exception:
em System.Windows.DependencyObject.GetValue(DependencyProperty dp)
em System.Windows.Media.Effects.PixelShader.ManualUpdateResource(Channel channel, Boolean skipOnChannelCheck) em System.Windows.Media.Effects.PixelShader.UpdateResource(Channel channel, Boolean skipOnChannelCheck) em System.Windows.Media.Effects.PixelShader.System.Windows.Media.Composition.DUCE.IResource.AddRefOnChannel(Channel channel) em System.Windows.Media.Effects.ShaderEffect.AddRefOnChannelCore(Channel channel) em System.Windows.Media.Effects.Effect.System.Windows.Media.Composition.DUCE.IResource.AddRefOnChannel(Channel channel) em System.Windows.Media.Visual.UpdateEffect(Channel channel, ResourceHandle handle, VisualProxyFlags flags, Boolean isOnChannel) em System.Windows.Media.Visual.RenderRecursive(RenderContext ctx) em System.Windows.Media.Visual.Render(RenderContext ctx, UInt32 childIndex) em System.Windows.Media.Renderer.Render(IntPtr pRenderTarget, Channel channel, Visual visual, Int32 width, Int32 height, Double dpiX, Double dpiY, Matrix worldTransform, Rect windowClip) em System.Windows.Media.Imaging.BitmapVisualManager.Render(Visual visual, Matrix worldTransform, Rect windowClip) em System.Windows.Media.Imaging.BitmapVisualManager.Render(Visual visual)
 
    