how to close a thread?
-
I have a second thread in my application, created like this:
Thread* secondThread; ThreadStart* second = new ThreadStart(this,my_method); secondThread = new Thread(second); secondThread->Start();
This thread does not close when I close down the application. I tried with "Abort". I guess I need some try-catch, but sot sure how to use it... tried with this in the generated dispose method...try{ secondThread->Abort(); } catch(char* szException){} components->Dispose;
...this didn´t work. Any suggestions as to how to close the thread. (doesn´t need to be "proffesional" as I´m just building a test app with really dirty coding...) Also...is the creation of the thread the "best" way to create a thread (I have seen a couple of different solution, though this was the one that I found easier imediately. regards, doneirik -
I have a second thread in my application, created like this:
Thread* secondThread; ThreadStart* second = new ThreadStart(this,my_method); secondThread = new Thread(second); secondThread->Start();
This thread does not close when I close down the application. I tried with "Abort". I guess I need some try-catch, but sot sure how to use it... tried with this in the generated dispose method...try{ secondThread->Abort(); } catch(char* szException){} components->Dispose;
...this didn´t work. Any suggestions as to how to close the thread. (doesn´t need to be "proffesional" as I´m just building a test app with really dirty coding...) Also...is the creation of the thread the "best" way to create a thread (I have seen a couple of different solution, though this was the one that I found easier imediately. regards, doneirik -
I have a second thread in my application, created like this:
Thread* secondThread; ThreadStart* second = new ThreadStart(this,my_method); secondThread = new Thread(second); secondThread->Start();
This thread does not close when I close down the application. I tried with "Abort". I guess I need some try-catch, but sot sure how to use it... tried with this in the generated dispose method...try{ secondThread->Abort(); } catch(char* szException){} components->Dispose;
...this didn´t work. Any suggestions as to how to close the thread. (doesn´t need to be "proffesional" as I´m just building a test app with really dirty coding...) Also...is the creation of the thread the "best" way to create a thread (I have seen a couple of different solution, though this was the one that I found easier imediately. regards, doneirikSee here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow