multithreading - C#, Thread, Memory -
today know how save image stream (really in memory it's possible don't use appropriate term) , read thread.
to think proceed these steps : - in first thread : 1 - create image object (system.drawing) file 2 - create thumbnail 3 - save thumbnail stream (system.io) 4 - send stream object second thread.
b - in second thread : 1 - receive stream first thread 2 - create bitmapimage object stream 3 - displaying on ui. (wpf)
thks.
i've retrieve part of code show did :
in thread check images in folders :
public void createimgobj(object sender) { try { filestream fs = file.open((string)sender, filemode.open); bitmap dimg = new bitmap(fs); memorystream ms = new memorystream(); dimg.save(ms, system.drawing.imaging.imageformat.jpeg); bitmapimage bi_img = new bitmapimage(); bi_img.begininit(); bi_img.streamsource = new memorystream(ms.toarray()); bi_img.endinit(); evt_send_img(bi_img); } catch (exception e) { evt_error(e); } }
in ui thread :
private void img_recieve(object sender) { try { dispatcher.begininvoke(dispatcherpriority.normal, new action(() => { items.add(new img { img_in = (bitmapimage)sender }); })); } catch (exception e) { messageerreur(e); } }
note : "img_recieve" execute "evt_send_img";
thks
Comments
Post a Comment