我已经构建了一个显示图像的WPF控件。现在我想以非常快的速度更改该图像。
我构建了一个ImageContainer类来持有该图像,并具有ChangedEventHandler,当该图像更改时更新我控件中的图像。
执行的代码如下:
执行的代码如下:
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();
}
}
}
这段代码会抛出一个System.Reflection.TargetInvocationException异常,我做错了什么?