Hi ng,
I have a very strange problem within my c# application:
One of the (background) Threads in my application is responsible for some
image processing tasks (like resizing, clipping, ..) on a list of files.
Therefore, some temporary files are created which should be deleted after
processing is finished.
This Thread is called several times. When I call it the first time,
everything's ok and no errors occur.
In the second call, I can observe very strange behaviour: I cannot delete
the temporary files created by this thread, but I'm sure that all image and
bitmap-objects are disposed after processing (with this method,which is, I
think more than should be necessary to release the file lock)
private static void DisposeImage(Image image)
{
image.Dispose();
image = null;
GC.Collect();
}
Did anyone observe similar behaviour? Does anyone have any ideas what could
be the reason for this annoying file locks (e.g. error in threading or
whatever..)
Or, how could a workaround look like (which means how can I unlock a file
which was created by the same thread)
thx,
Albert 4 13577
You should always make sure that you close the streams used to load the
images as well.
Maybe that is the problem you're experiencing?
--
Patrik Löwendahl [C# MVP] http://www.lowendahl.net/ || http://www.cshrp.net
Albert Greinöcker wrote: Hi ng,
I have a very strange problem within my c# application: One of the (background) Threads in my application is responsible for some image processing tasks (like resizing, clipping, ..) on a list of files. Therefore, some temporary files are created which should be deleted after processing is finished. This Thread is called several times. When I call it the first time, everything's ok and no errors occur. In the second call, I can observe very strange behaviour: I cannot delete the temporary files created by this thread, but I'm sure that all image and bitmap-objects are disposed after processing (with this method,which is, I think more than should be necessary to release the file lock) private static void DisposeImage(Image image)
{ image.Dispose(); image = null; GC.Collect(); }
Did anyone observe similar behaviour? Does anyone have any ideas what could be the reason for this annoying file locks (e.g. error in threading or whatever..) Or, how could a workaround look like (which means how can I unlock a file which was created by the same thread)
thx, Albert
Thanks for your response...
The only two ways I'm opening the images is either
Image img = Image.FromFile(filePath);
Or with a copy constructor
Are in this case any additional closing steps necessary?
""Patrik Löwendahl [C# MVP]"" <pa******************************@home.se>
schrieb im Newsbeitrag news:OX**************@tk2msftngp13.phx.gbl... You should always make sure that you close the streams used to load the images as well.
Maybe that is the problem you're experiencing?
-- Patrik Löwendahl [C# MVP] http://www.lowendahl.net/ || http://www.cshrp.net
Albert Greinöcker wrote: Hi ng,
I have a very strange problem within my c# application: One of the (background) Threads in my application is responsible for some image processing tasks (like resizing, clipping, ..) on a list of files. Therefore, some temporary files are created which should be deleted after processing is finished. This Thread is called several times. When I call it the first time, everything's ok and no errors occur. In the second call, I can observe very strange behaviour: I cannot delete the temporary files created by this thread, but I'm sure that all image and bitmap-objects are disposed after processing (with this method,which is, I think more than should be necessary to release the file lock) private static void DisposeImage(Image image)
{ image.Dispose(); image = null; GC.Collect(); }
Did anyone observe similar behaviour? Does anyone have any ideas what could be the reason for this annoying file locks (e.g. error in threading or whatever..) Or, how could a workaround look like (which means how can I unlock a file which was created by the same thread)
thx, Albert
I'm not a 100% for the implementation of file reading in GDI.
But I would try not to use a filename but instead use a filestream which
you could explicitly close.
--
Patrik Löwendahl [C# MVP] http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.
Albert Greinöcker wrote: Thanks for your response...
The only two ways I'm opening the images is either
Image img = Image.FromFile(filePath);
Or with a copy constructor
Are in this case any additional closing steps necessary? ""Patrik Löwendahl [C# MVP]"" <pa******************************@home.se> schrieb im Newsbeitrag news:OX**************@tk2msftngp13.phx.gbl...
You should always make sure that you close the streams used to load the images as well.
Maybe that is the problem you're experiencing?
-- Patrik Löwendahl [C# MVP] http://www.lowendahl.net/ || http://www.cshrp.net
Albert Greinöcker wrote:
Hi ng,
I have a very strange problem within my c# application: One of the (background) Threads in my application is responsible for some image processing tasks (like resizing, clipping, ..) on a list of files. Therefore, some temporary files are created which should be deleted after processing is finished. This Thread is called several times. When I call it the first time, everything's ok and no errors occur. In the second call, I can observe very strange behaviour: I cannot delete the temporary files created by this thread, but I'm sure that all image and bitmap-objects are disposed after processing (with this method,which is, I think more than should be necessary to release the file lock) private static void DisposeImage(Image image)
{ image.Dispose(); image = null; GC.Collect(); }
Did anyone observe similar behaviour? Does anyone have any ideas what could be the reason for this annoying file locks (e.g. error in threading or whatever..) Or, how could a workaround look like (which means how can I unlock a file which was created by the same thread)
thx, Albert
I'm also not very happy with the GDI-implementation...
which alternative would you advice?
""Patrik Löwendahl [C# MVP]"" <pa******************************@home.se>
schrieb im Newsbeitrag news:%2****************@TK2MSFTNGP12.phx.gbl... I'm not a 100% for the implementation of file reading in GDI.
But I would try not to use a filename but instead use a filestream which you could explicitly close.
-- Patrik Löwendahl [C# MVP] http://www.lowendahl.net/ || http://www.cshrp.net Please reply only to the newsgroup.
Albert Greinöcker wrote: Thanks for your response...
The only two ways I'm opening the images is either
Image img = Image.FromFile(filePath);
Or with a copy constructor
Are in this case any additional closing steps necessary? ""Patrik Löwendahl [C# MVP]"" <pa******************************@home.se> schrieb im Newsbeitrag news:OX**************@tk2msftngp13.phx.gbl...
You should always make sure that you close the streams used to load the images as well.
Maybe that is the problem you're experiencing?
-- Patrik Löwendahl [C# MVP] http://www.lowendahl.net/ || http://www.cshrp.net
Albert Greinöcker wrote:
Hi ng,
I have a very strange problem within my c# application: One of the (background) Threads in my application is responsible for some image processing tasks (like resizing, clipping, ..) on a list of files. Therefore, some temporary files are created which should be deleted after processing is finished. This Thread is called several times. When I call it the first time, everything's ok and no errors occur. In the second call, I can observe very strange behaviour: I cannot delete the temporary files created by this thread, but I'm sure that all image and bitmap-objects are disposed after processing (with this method,which is, I think more than should be necessary to release the file lock) private static void DisposeImage(Image image)
{ image.Dispose(); image = null; GC.Collect(); }
Did anyone observe similar behaviour? Does anyone have any ideas what could be the reason for this annoying file locks (e.g. error in threading or whatever..) Or, how could a workaround look like (which means how can I unlock a file which was created by the same thread)
thx, Albert
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pekka Niiranen |
last post by:
Hi,
I have used the following example from win32 extensions:
-----SCRIPT STARTS----
import win32file
import win32con
import win32security
import pywintypes
|
by: Lokkju |
last post by:
I am pretty much lost here - I am trying to create a managed c++
wrapper for this dll, so that I can use it from c#/vb.net, however, it
does not conform to any standard style of coding I have seen....
|
by: Fabio R. |
last post by:
To support a webfarm scenario, I'd like to store a global array (serialized)
in a file on a network share.
In this array there is a list of pages "locked" by other users so I need to
read this...
|
by: hkappleorange |
last post by:
I ued this code to connect to a mdb file
A = New OleDbConnection( "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA
Source=C:\Inetpub\wwwroot\ASPX\Authors.mdb" )
|
by: troutbum |
last post by:
I am experiencing problems when one user has a document open through a
share pointing to the web site. I use the dsolefile to read the
contents of a particular directory and then display them in a...
|
by: ABCL |
last post by:
Hi All,
I am working on the situation where 2 different
Process/Application(.net) tries to open file at the same time....Or one
process is updating the file and another process tries to access...
|
by: cmay |
last post by:
The only examples I have seen on how to check if a file is locked is to
try to open it a catch an exception.
MS has stated that you should never use error trapping in this manner.
Is there no...
|
by: elake |
last post by:
I found this thread about a pst file in Windows being locked and I am
having the same issue.
...
|
by: Dmitry Teslenko |
last post by:
Hello!
I use some script in python 2.5 from vim editor (it has python
bindings) that updates some file
and then launches another program (ms visual studio, for example) to
do something with...
|
by: Gabriel Genellina |
last post by:
En Tue, 13 May 2008 11:57:03 -0300, Dmitry Teslenko <dteslenko@gmail.com>
escribió:
Is the code above contained in a function? So all references are released
upon function exit?
If not, you...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |