I've built a WPF Control which displays an Image. Now I would like to change that image at a very fast rate. I've build an ImageContainer class which holds the image and has a ChangedEventHandler which updates the Image in my control when changed.
The code which is executed 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, what am I doing wrong?