I have a problem in my multithreaded application. The problem is reproducible
very rarely, only once in 6000 similar execution (through same code path).
Problem: One of multiple threads gets abnormally terminated. It does not
goes through the try-catch-finally sequence. The mehtod gets hanged and the
object used inside the method gets collected by GC.
Bacground about the application: I am using COM-Interop. The threads are
created in unmanaged code which calls methods from managed code. One of the
thread abnormally terminates when executing .NET method.
Observation: I have observed that the thread terminates only in those
methods where I am using IO Stream operation.
As I said this is very rare and the same code works fine except once or
twice in 6000 executions.
This is the code under which thread terminates mostly.
<CODE>
// I am generating log file for comments, to see the actual execution path
public string GetRequestFile(string strFileName)
{
// Log method enterd
StreamReader reader = null;
try
{
reader = new StreamReader(strFileName);
return reader.ReadToEnd();
}
catch(Exception exc)
{
// Log error occurred
throw;
}
finally
{
if(reader != null)
reader.Close();
// Log finally executed
}
}
<CODE>
Please let me know if there is any similar bug reported under .NET I/O
Stream operation.
Thanks in advance for your help.
Cheers,
Rahul Anand