Re: System.Drawing.Image.FromFile leaves file open longer than necessary: bug?
From: Lucvdv (replace_name_at_null.net)
Date: 08/02/04
- Previous message: Valery Pryamikov: "Re: bool - thread safety"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 02 Aug 2004 08:53:49 +0200
On Fri, 30 Jul 2004 05:10:52 -0700, "David Williams , VB.NET MVP"
<davidd.NOSPAM.williams@earthlink.net> wrote:
> No, explicitly running Collect() is normally a bad idea - it will
> adversely impact the performance of your code and can cause other
> problems.
That may depend on the situation. I found out in a DirectX application
that has to run for long stretches of time (12 hours or more of
uninterrupted D3D rendering in an applications that's controlled by events
it receives at a constant rate of several events/second), it's better to
force it at regular small intervals to prevent it from causing a noticeable
load on the system when it finally does it by itself.
> The best way that I have found to handle this problem is to load the
> image from a stream object that you control instead of directly from a
> file. This way you can use the image as long as you need, but close and
> dispose the stream as soon as you are done reading it.
I noticed it in a test program I wrote to find the best way to handle the
TWAIN capture, but the real app saves and reads small jpegs into/from a
database (ID photographs in a people database). I was already planning to
load them into a byte array for doing the database side and make a memory
stream out of the same array for copying into the picturebox, so that would
automatically become the solution.
- Previous message: Valery Pryamikov: "Re: bool - thread safety"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|