OpenNetCF.Drawing.Imaging Problem

T

Tomppa

I've got an issue with IImage.Draw().



I have a screen saver type application where I display images in a loop.



IImage.Draw can run for up to 20 seconds sometimes as the images are about 6
MegaPixels in size.



The loop runs great all day until I add another process to the application.
An example would be an async socket that receives data and raises an event.



If this happens when IImage.Draw is active it causes IImage.Draw to fail.



In addition any further calls to IImage.Draw will fail until the app is
restarted.



I tried launching my imaging function on a separate thread to isolate the
functionality but the same thing happens.

It runs great until another process takes place (in the main thread) while
IImage.Draw is active (on a separate thread)

It then errors out and additional calls to the function fail.



My function first creates an iiImage as follows



stm = new StreamOnFile(_path);

hr = factory.CreateImageFromStream(stm, out iiImage);



This functionality will continue to function across failures.



I know that iiImage is valid here because the following code returns a valid
ImageInfo



OpenNETCF.Drawing.Imaging.ImageInfo imageInfo;

iiImage.GetImageInfo(out imageInfo);



It is only the IImage.Draw that quits working.



It appears that IImage.Draw is not being disposed of and is left in a bogus
state???



Would a possible solution be for IImage to inherit IDisposable????



Ideally I would like to prevent the failures but I need to be a able to
recover if it occurs?



Any thoughts?
 
A

Alex Feinman [MVP]

To dispose of IImage object you could call Marshal.FinalReleaseComObject()
IImage cannot inherit IDisposable since it is an import for an external COM
object. Another class can be created that wraps it and provides extended
functionality and cleanup.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top