I am using main window as context, which has an image bound to a byte[], like this
MainWindow : INotifyChanged { byte[] _image; ImageContent { get {return _image;} } Main() { this.Context = this; } private void Polling() { while() { //download image NotifyPropertyChanged("ImageContent"); } } NotifyPropertyChanged(string propertyname) { if(PropertyChanged != null) { PropertyChanged(propertyname); } } } and the xaml has <image source = {binding = ImageContent} />
and the problem is, I am downloading 10 images in 1 second, if I change the url to download another image, ImageControl will flicker between different image from the two sources for a while.
I think this is because my polling is faster than Image control update, and some event handler is queued inside WeakEventManager, I have search and be told that there is no easy way to clean up queued event.
I tried WeakEventManager.GetCurrentManager(), Visual Studio tells me that there is no such method. I have tried OnLoad, OnSourceChaneged, OnTargetChanged, non of them was fired weak event.
Could anyone please tell me how do I resolve this? with or without weak event. ?
I would like to get rid of that flickering.