none
Multithreading strategy RRS feed

  • Question

  •  

    Hi everyone,

     

    my app requires the user to load several images. To save time and effort, the user can make a multiple selection in the OpenFileDialog object and the app goes through the selection list one by one loading images and doing various things. My question is: would it be beneficial to thread this operation (new threads trying to load one image each)? Some of these images are very large and can take a little while to load. It seems as if the threads would be competing for hard disk access though, slowing things down rather than speeding them up. Is it wise to do it this way?

    Wednesday, August 22, 2007 7:56 PM

All replies

  • it all depends, you want to be careful with moving to multithreading with controls (or a webpage). If you need to download the pictures, load them into memory, and then show them it might make sense to do the downloading and loading into memory on a different thread and use events to cause them to show. Otherwise you'll run into too many problems, especially with making it one thread per image. Threads will be competing for more than just hard disk access.

    Without knowing what you're doing and when, I can't really suggest much changes.
    Wednesday, August 22, 2007 9:18 PM
  • If you can assume higher quality hard disks (SCSI) or external storage (as in a server environment) then multi-threading won't hurt performance.

     

    Another option is to use a staged solution: Have one thread which reads the images into memory, and another thread which displays them to the user. This allows you to use your two resources (hard disk and graphics card) in parallel.

     

    You might also want to check out some of the threading articles on my blog [http://udidahan.weblogs.us/category/threading/]

     

    Hope that helps.

     

    Friday, August 24, 2007 6:47 AM