Search Results

Search found 2 results on 1 pages for 'impz0r'.

Page 1/1 | 1 

  • Question about WeakReferences

    - by Impz0r
    Hey there, I've got a question regarding WeakReferences. I'm right now in the process of writing a "Resource Manager" who hast to keep references to created texture objects. I have a Dictionary like: Dictionary<uint, WeakReference> Where the first is, as you allready may guessed, the Resource Id and the second param is a WeakReference to the Resource itself. Right now my Resources do have a method to free themselfes from their Owner (i.e. Resource Manager). They do so in calling a method at the Resource Manger while passing a this reference to it. The ResMgr does lookup if it is a resource he keeps bookmark of and if so, does something like this: WeakReference result; if (m_Resources.TryGetValue(ResourceId, out result)) { if (result.IsAlive) return; (result.Target as Resource).free(); // free for good m_Resources.Remove(ResourceId); } The Problem I'm having is that the part after: if (result.IsAlive) is never reached because there are still leftover references to the Resource. The thing is, I do only have one Reference of the Resource in question and it releases itself like: resource.free(); // calls internally its owner (i.e. ResMgr) resource = null; I guess the left over reference would be the "resource" variable, but I cannot set it to null, because I do have to call free first. Quite a dilema... Well what I wanted to achive with this is a Resource Manager who keeps references to its owning Resources and release them ONLY if there is no reference left to not screw up something. Any idea how I may solve this in a clean fashion? Thanks in advance! Mfg Imp

    Read the article

  • Question about C# properties

    - by Impz0r
    Hey there, i bumped the other day into a little problem regarding C#'s properties. Let's say i do have this setup: public class Point { public float X; public float Y; } public class Control { protected Point m_Position = new Point(); public Position { get { return m_Position; } set { m_Position = value; } // reorganize internal structure.. reorganize(); } protected reorganize() { // do some stuff } } This is all fine, but when it comes to usage, i could write something like: Control myControl = new Control(); myControl.Position.X = 1.0f; The thing is, my Control class wont recognize that the Position has been changed because set hasn't been called. So i guess my question is, is there a way to make Control aware of any Position changes? Thanks in advance! Mfg Imp

    Read the article

1