c# - Threading with ImageDrawings and freeze -
i have problem creating image in background-thread. have main-icon (16x16 pixel) should merged other icons, can overlay. code this:
private void generateconnectionicon() { var dgr = new drawinggroup(); var newgroupitem = new imagedrawing(_connectionicon, new rect(0, 0, 16, 16)); newgroupitem.freeze(); //here throws expection dgr.children.add(newgroupitem); foreach (var anoverlay in _connectioniconoverlays) { dgr.children.add(new imagedrawing(anoverlay, new rect(0, 0, 16, 16))); } dgr.freeze(); var finalicon = new drawingimage(dgr); finalicon.freeze(); _connectioniconmerged = finalicon; }
the code quits in 3rd line because calling thread not owner of object. little bit confused this, because object created 1 line above. variable _connectionicon
imagesource
, freezed.
the exact error message the calling thread cannot access object because different thread owns it
.
why cannot freeze object, created 1 line above?
c# wpf multithreading freezable
No comments:
Post a Comment