IImage locks files on disk

Last post 10-01-2008 9:53 by Kristoffe. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 10-01-2008 9:53

    IImage locks files on disk

    Hi all, I'm using transparency on wince 6 by using IImages and an IImagingFactory. This works ok, but i have one problem. The files are kept open after they are read into memory. I have an in program updating function that i want to use to update those bitmaps but i constantly bump into the problem that they are still in use.

    As far as i can see it seems that the CreateImageFromFile keeps a lock on the file after it has been read. Is there any way i can tell it to release the file so that it can be updated? I also store them in a local dictionary for faster access once they have been loaded once, but removing those does not seem to solve anything. My function is below: 

    public IImage GetCachedIImage(string reference)
            {
                reference = GetFolderPath(reference);
                if (reference == null)
                    return null;

                BufferKey key = new BufferKey(reference, typeof(IImage));
                if (dictionary.ContainsKey(key))
                    return (IImage)dictionary[key];

                IImage imagingImage;
                factory.CreateImageFromFile(reference, out imagingImage);
                if (imagingImage != null)
                    dictionary.Add(key, imagingImage);
                return imagingImage;
            }

     

    thanks in advance for any insights on this,

    Kristof

Page 1 of 1 (1 items)