Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6827743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:18:04+00:00 2026-05-26T22:18:04+00:00

Currently my program reads images and text in a record from an xml file,

  • 0

Currently my program reads images and text in a record from an xml file, displays them on the screen, and then the click of the previous/next buttons moves to the next record. However, it seems to need a few seconds loading time between each photo and I’d like it to be instant, like how Windows Photo Gallery would…or Facebook photos (bear in mind this is not a web app).

I searched found a few similar situations to mine but none seemed to fit my situation. I tried making a class, based on my search, to deal with background loading and calling it in my program, but it’s fraught with error and probably won’t even do what I want it do:

//ImageManager.cs

class ImageManager
{
    private Dictionary<string, Image> images = new Dictionary<string, Image>();

    public Image get(string s)
    {  // blocking call, returns the image
        return load(s);
    }

    private Image load(string s)
    {  // internal, thread-safe helper
        lock (images)
        {
            if (!images.ContainsKey(s))
            {
                Image img = images.Add(s, img); //load the image s - ERROR cannot implicitly convert type void to image. Void??
                return img;
            }
            return images[s];
        }
    }

    public void preload(params string[] imgs)
    {  // non-blocking preloading call
        foreach (string img in imgs)
        {
            BackgroundWorker bw = new BackgroundWorker();
            bw.DoWork += (s, e) => { load(img); };  // discard the actual image return
            bw.RunWorkerAsync();
        }
    }
}


//MainWindow.cs

ImageManager im = new ImageManager();
im.preload("Data/Images"); // Errors - im is a field but used like a type/token '('

Many thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:18:04+00:00Added an answer on May 26, 2026 at 10:18 pm

    Your ImageManager should work with ImageSources, not Images. Even if you get your current code to work you’ll find that your UI still hangs because you have no choice but to perform the work on the UI thread. If you instead deal with ImageSources, you can load them on a background thread and then freeze them in order to use them from the UI thread. This frees you to pre-emptively load images, or to show a loading animation whilst they load.

    BitmapFrame.Create is likely the method you want to be using to load the images.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently writing a program that reads records from a txt file and
I currently have a simple database program that reads keys in from a text
Currently, I have a program that reads a file and uses an XMLTextWriter to
I have a MS sql database (not server), my program reads file structure from
Currently when I open a file with my program I can select files on
I have a wxPython program which reads from different datasets, performs various types of
I am currently making a small test program for simple file checking. The program
I have written a program which reads a file containing multidimensional data (most commonly
I wrote a simple program that reads the characters from external device (bar code
Currently my program is in a spot where it both listens for the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.