B4J Question Load Image - Multithreaded ? Possible ?

Discussion in 'B4J Questions' started by jmon, Jul 17, 2015.

  1. jmon

    jmon Well-Known Member Licensed User

    Hi,

    Is it possible to load an image into an imageView on a separate thread?
    I have lots of images to load and it's taking too much time to do the loadImageSample right now.

    I'm thinking that the best solution would be to load them in a webView, but I was wondering if someone had a better idea?

    Thank you.
    Jmon.
     
  2. Roycefer

    Roycefer Well-Known Member Licensed User

    Loading the images from your hard drive into RAM won't be sped up by multi-threading (and it might even be slowed down) though your overall program execution time might go down if you get that task off the main thread so that UI events can execute. Down-sampling an image (especially a large one) might be CPU-intensive enough to benefit from multi-threading. Loading the down-sampled image into an ImageView must be performed on the UI thread, which means it has to be single-threaded. If you choose to go the multi-threaded route, I suggest you don't use any more threads than you have Hyper-Threaded cores as you'll start to lose performance above that number.
     
    jmon likes this.
  3. jmon

    jmon Well-Known Member Licensed User

    Thanks.

    Yes my idea was to keep the app responsive while I load the images.

    I thought also about having a list of image to load and load them one by one with a timer instead of all at the same time in a single loop.
     
  4. Roycefer

    Roycefer Well-Known Member Licensed User

    Yeah, a timer would work, as well. It'll probably take longer but your app would remain responsive.
     
    jmon likes this.
Loading...