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

  • Home
  • SEARCH
  • 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 6699441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:41:43+00:00 2026-05-26T06:41:43+00:00

Is a class such as this necessary? public class ContentCache { private readonly ContentManager

  • 0

Is a class such as this necessary?

public class ContentCache
{
    private readonly ContentManager _content;
    private readonly Dictionary<string, Texture2D> _textureCache = new Dictionary<string, Texture2D>();

    public ContentCache(ContentManager content)
    {
        _content = content;
    }

    public Texture2D Load(string assetName)
    {
        Texture2D texture = null;
        if (!_textureCache.TryGetValue(assetName, out texture))
        {
            _textureCache[assetName] =
                texture = _content.Load<Texture2D>(assetName);
        }
        return texture;
    }
}

I am curious if ContentManager.Load<Texture2D>() does it’s own caching internally. I don’t want to double-cache things.

Note:

Our XNA game is 2D and going to run on WP7 and Windows, and also iOS and OSX using MonoGame.

MonoGame may function differently than XNA in Windows, but I can probably browse it’s source to find that out.

  • 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-26T06:41:44+00:00Added an answer on May 26, 2026 at 6:41 am

    The class is unnecessary. ContentManager does this on your behalf.

    Source:

    http://forums.create.msdn.com/forums/p/31383/178975.aspx

    Note:

    As far as Mono goes… I’m sure the implementations mirror each other quite well, but I can’t be certain on this occasion.

    Also, if you WANT to re-load an asset, you could use an additional ContentManager and throw it away afterward.

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

Sidebar

Related Questions

Given a class such as: class Person { private: char *name; public: Person() {
I have such class public unsafe class EigenSolver { public double* aPtr {get; private
Suppose I have Dictionary like this: Dictionary<string, string> values = new Dictionary<string, string>() {
While striving for const-correctness, I often find myself writing code such as this class
If I have a base class such that public abstract class XMLSubscription <T extends
If I have a simple class such as:- @XmlRootElement public class MyClass { @XmlAttribute(required=true)
In AS3, if I have a class such: public class dude { //default value
Java lets you create an entirely new subtype of Throwable , e.g: public class
I have class: public class GenericDAO<T, ID extends Serializable> { private final EntityManager em;
i do this in the education purpose. such is idea: i have class Array.

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.