Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download image synchronously in background?

I have a background worker which I use to get some data from a web server. It's required to download some images (png or jpg) also. But every time I try to create BitmapImage or WriteableBitmap in the background worker thread I get Invalid cross-thread access Is it ever possible to load image in background not UI thread?

like image 950
Shedon Avatar asked Nov 28 '25 00:11

Shedon


1 Answers

use this it will work for you.

Deployment.Current.Dispatcher.BeginInvoke(() =>
                {
                    //write here whatever you want to update on screen.
                    textblock.Text = "text changed";
                    // just like this line changed the text of a textblock
                });

if it does not work paste your code.

like image 170
Mohit Avatar answered Nov 30 '25 16:11

Mohit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!