C# wpf BitmapImage 跨线程访问

//直接跨使用BitmapImage报异常 不能跨线程访问BitmapImage对象

//借助BitmapFrame 来访问


 var img = new BitmapImage(new Uri(fileName));

            this.imgControl.Dispatcher.Invoke(new Action(delegate
            {
                BitmapFrame frame = BitmapFrame.Create(img);
                this.imgControl.Source = frame;
            }));

猜你喜欢

转载自blog.csdn.net/zh_98/article/details/78225197