I created a WPF control that displays an image. Now I would like to change this image at a very high speed. I created an ImageContainer class that contains an image and has a ChangedEventHandler that updates the image in my control when it changes.
The executed code looks like this:
videoImageThread = new Thread(
new ThreadStart(
delegate()
{
this.VideoCapture.Dispatcher.Invoke(
System.Windows.Threading.DispatcherPriority.Normal,
new Action(
delegate()
{
videoImage.Source = VideoImageContainer.Instance.VideoBitmapSourceImage;
}
));
}
));
private void Instance_VideoRefresh()
{
if (VideoImageContainer.Instance.VideoImage != null)
{
lock (videoImageSetLock)
{
videoImageThread.Start();
}
}
}
This code throws a System.Reflection.TargetInvocationException exception, what am I doing wrong?
source
share