Re: System.Drawing.Image.FromFile leaves file open longer than necessary: bug?

From: Lucvdv (replace_name_at_null.net)
Date: 08/02/04

  • Next message: Jack Wright: "How to ensure that your .Net application is running in the right .net runtime version?"
    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.


  • Next message: Jack Wright: "How to ensure that your .Net application is running in the right .net runtime version?"

    Relevant Pages

    • Re: Check if any items in an array (php) is in a table (mysql).
      ... I want to check the ship record (a table in a MySQL database) to check ... I could brute force it and increment through the "to be shipped array" ... Load the shipped table as an associative array and then do an isseton the $arrayin question. ...
      (comp.lang.php)
    • Re: Tricky explode(), help please!
      ... When I load this information into the database, ... explodefunction to break this array down into its parts, ... and load output file when all rows have been ...
      (comp.lang.php)
    • Tricky explode(), help please!
      ... I am trying to parse and load a tab delimited file into a mysql ... When I load this information into the database, ... explodefunction to break this array down into its parts, ...
      (comp.lang.php)
    • Re: SQL Server, MS Word and C#.
      ... You should be able to load your document into an array, ... > I want to insert some word files into the database and also be able to> retreive them. ... > 1) What DataType should the fiel be in the DB. ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Load Image from a byte array
      ... Not sure if this is possible, but the BitMap class is able to get it's data ... from a stream, so I'd guess you should be able to create is based on a ... the same as a byte array and need to load the image from this. ...
      (microsoft.public.dotnet.framework)