Well sooner or later someone is gonna get tired of looking at my threading questions but a ton of progress is being made and I really appreciate all the help, anyways anyone who has read my previous posts can see that my application connects to a MSSQL database and calls a stored proceedure to dump all the data and that data dump is in a thread of its own so that the gui still functions while its dumping the data. Anyways one of the buttons in the GUI is used to disconnect from the database while its performing this dump or atleast that is what I would like it to do. I've already figured out that you have to redfine the thread etc. after its been aborted to start it up agian and aborting it seems to work as long as the entire stored proceedure has been executed using the thread.abort() command. What I would like to do is have the dump code just stop as soon as the disconnect button is clicked instead of having to wait for the code to finish executing than aborting itself, the reason for this is because the application can be exporting upwards of a million data entries which seems to take a decent amount of time and having to wait for it to complete before exiting the thread makes the program appear to hang.
Any help would be much appreciated, I think this will most likely be the last threading question I have.

Terminating threads immediatly upon button click.
fMarkf
But please check the warnings in the Thread.Abort section. There are good reasons to avoid doing this. The general recommendation when using multiple threads is to *not* use Thread.Abort.
Best regards,
Johan Stenberg
Joel Martinez
As an alternative, consider using the SqlCommand.BeginExecuteNonQuery() method. It starts the stored procedure and immediately returns. You can try using the Cancel method to abort the stored procedure. Bonus: you don't have use a thread anymore, your GUI will stay responsive...
h1
R.K.S.
You don't need to have the thread abort its self. You can have the UI thread abourt your worker thread.
If you save off an instance to the thread you create in a variable on your form, you can call the abort method on it from your UI thread. This will then kill it immedietly. Something like this should work:
dim t = new Thread(...)
t.Start()
'decide to kill thread
t.Abort()
-Scott Wisniewski