Calling method on different Thread?

  • Thread starter Thread starter Torben Philippsen
  • Start date Start date
T

Torben Philippsen

Hello!

In my application I am executing some sql statements on a different thead.
For that task I have created an ExeCuteSQLCOmmand class.

When pressing run in my mail application the following happens:

void run()
{
executeSQLCommand = new ExecuteSQLCommand(getTextConstants(), null,
getConnection(), getOdbcConnection(), statements);
ThreadStart executeSQLCommandThreadStart = new
ThreadStart(executeSQLCommand.run);
Thread executeSQLCommandThread = new Thread(executeSQLCommandThreadStart);
executeSQLCommandThread.Start();
}

In the ExecuteSQLCommand class i have implementet a cancel method, that
cancels all sql statements from being executed. My problem is when calling
this method from my main application:
executeSQLCommand.cancel();

I get multiple errros saying that some of my objects used to execute sql
statements (OdbcConnection, OdbcCommand, OdbcReader) aren't set to an
instance of an object - but they are??
Do you have any idea what I am doing wrong?

I haven't got great experience in running applications on more than one
tread, any help would really be appreciated.

Thank you very much
Torben
 
Hi Jon!

Thank You for your reply.
Making a short complete program is not easy doable, but I will look into it
and repost.

I appreciate your help.

Best regards Torben
 
Back
Top