M
Miguel
Hey, Hi all friends!!!
I've got an application which executes an stored procedure
using an OdbcCommand object, but it has to executes
several stored procedures at the same time, so i decided
use multithreading, so that the application creates a
thread for each stored procedure and start it in this way
class ClassWithMethod
{
public void MyMethod()
{
//here stored procedure executes
}
}
class Test
{
static public Main (string[] args)
{
ClassWithMethod obj = new ClassWithMethod();
Thread myThread = new Thread (new ThreadStart
(obj.MyMethod));
myThread.Start();
}
}
But in the application a new thread is created each time
an event happens, and each time a thread is created the
application is creating a new OdbcConnection (ODBC 'cause
it uses a Sybase 10 database) and it is closing the
connection in the finally block of the method MyMethod
(describe before) but, to close the connection the
application is verifying that the connection it is gonna
close be an open connection, if it is not an open
connection it throws an exception, and my problem is that
this exception i mentioned is throwing in some cases, i.e.
just in some cases, i.e. in some thread which the
connection is trying to be closed, the application detects
that this connection of this thread is closed.
So, anyone can undarstand why is happennig this???
or is there a better or more efficcient way to manage
connections in multithreading????
Any help i will thank!!!
Regards!!!!
I've got an application which executes an stored procedure
using an OdbcCommand object, but it has to executes
several stored procedures at the same time, so i decided
use multithreading, so that the application creates a
thread for each stored procedure and start it in this way
class ClassWithMethod
{
public void MyMethod()
{
//here stored procedure executes
}
}
class Test
{
static public Main (string[] args)
{
ClassWithMethod obj = new ClassWithMethod();
Thread myThread = new Thread (new ThreadStart
(obj.MyMethod));
myThread.Start();
}
}
But in the application a new thread is created each time
an event happens, and each time a thread is created the
application is creating a new OdbcConnection (ODBC 'cause
it uses a Sybase 10 database) and it is closing the
connection in the finally block of the method MyMethod
(describe before) but, to close the connection the
application is verifying that the connection it is gonna
close be an open connection, if it is not an open
connection it throws an exception, and my problem is that
this exception i mentioned is throwing in some cases, i.e.
just in some cases, i.e. in some thread which the
connection is trying to be closed, the application detects
that this connection of this thread is closed.
So, anyone can undarstand why is happennig this???
or is there a better or more efficcient way to manage
connections in multithreading????
Any help i will thank!!!
Regards!!!!