R
Richard Arthur
This is a weird problem.
1) I use MediaDet to save a bitmap in a temporary file.
2) I create a bitmap using that temporary file's name.
3) I use the bitmap.
4) I want to destroy the file when the process exits, but I am having
trouble
I have written a Finalizer on the object that actually generates the
bitmaps, as well as implementing IDisposable. The finalizer gets called, I
then call Dispose on each of the bitmaps it the object has created, and then
I call File.Delete() to delete the file used to create the bitmap.
If I call Dispose explicitly on the object in a form's Dispose method, this
works fine. If I close it in the event handler for the "Close" event, it
works fine, but if I let the garbage collector Finalize the object itself,
then this does not delete the files. It throws an IOException (which I
catch), saying that the object is in use by another process.
How can I make this object so that it cleans itself up properly? It is
going to be used by other people, so I do not want to give them too much
documentation overhead.
Richard Arthur
1) I use MediaDet to save a bitmap in a temporary file.
2) I create a bitmap using that temporary file's name.
3) I use the bitmap.
4) I want to destroy the file when the process exits, but I am having
trouble
I have written a Finalizer on the object that actually generates the
bitmaps, as well as implementing IDisposable. The finalizer gets called, I
then call Dispose on each of the bitmaps it the object has created, and then
I call File.Delete() to delete the file used to create the bitmap.
If I call Dispose explicitly on the object in a form's Dispose method, this
works fine. If I close it in the event handler for the "Close" event, it
works fine, but if I let the garbage collector Finalize the object itself,
then this does not delete the files. It throws an IOException (which I
catch), saying that the object is in use by another process.
How can I make this object so that it cleans itself up properly? It is
going to be used by other people, so I do not want to give them too much
documentation overhead.
Richard Arthur