multithread and database connection problem

  • Thread starter Thread starter Sam
  • Start date Start date
S

Sam

Hi,
When I load my form I start a new threads that creates a datareader,
which gets data from my database.

The problem is that I'd like to be able to abort the thread when
clicking on another button, otherwise there is an attempt at creating a
second datareader, while the thread is still running.

To do that I call myThread.Abort() on the click event of the button,
but for some reason instead of going from the Running state to the
Aborted state, it goes into AbortRequested state, and that's it! hence
the crash...

can you help?
 
I put a sample application here, if you feel like checking my code....

http://graphicsxp.free.fr/TestThreads.zip

Click on 'Execute Threads', and then click again or click on 'Execute
other Thread' (which actually don't start another thread.. i should
have changed the label, sorry) and then you should get the crash I have
now.

note: of course you need to change the connection string in the global
module, and call a stored procedure of your own.

Thanks !
 
Back
Top