multithread and database connection problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sam

    #1

    multithread and database connection problem

    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?

  • Sam

    #2
    Re: multithread and database connection problem

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



    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 !

    Comment

    Working...