Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

closing threads

Posted on 2003-11-24
6
Medium Priority
?
1,026 Views
Last Modified: 2011-09-20
How do I end a thread?

I used the sample code below to execute the thread:

procedure Form1.Button1CLick();
var vThread : Integer;
begin
      vThread := Thread.create(False);
end;

When I click Button2, the Thread should stop... How can I do that?
I thought of using ExitThread but I dont know how to use the GetExitCodeThread function to get the exit code of the thread.

PLease help... thanks
0
Comment
Question by:LORD_CHO
  • 2
4 Comments
 
LVL 5

Accepted Solution

by:
snehanshu earned 100 total points
ID: 9816084
To stop a thread,
  1) Buy ExEx premium services
  2) Search in Delphi TA for Thread stop
  3) Click on this link from the search results
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20390347.html

;-)
NOTE: 1 and 2 are now not required, may be for your next Q!

HTH,
...Snehanshu
0
 

Author Comment

by:LORD_CHO
ID: 9816774
hi ...Snehanshu
  thanks fo replying...

I did the example you have in your 3rd comment, but I always get "Access Violation" after executing the program. You see, my Thread (.execute) is located in Unit2...... But I am stopping it from unit1...
I have included the Unit2 in the uses of  Unit1... but still I receive the access violation.
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 9817483
LORD_CHO,

  I do not know too much about threads, but can you provide code related to your thread in both units (of how you are creating and terminating )?
  I'll try, but if not me, others might be able to help.

...Shu
0
 
LVL 5

Assisted Solution

by:Hypoviax
Hypoviax earned 100 total points
ID: 9822557
Shehansu Hi seen you around alot lately,

Any way LORD_CHO how about you try wrapping a try except block around the code in Shehansu's code. This may help prevent the violation from occuring. Use the red dot things to trace the place where the violation is occuring but first of all use the try except. You will still see the error in delphi unless you turn stop on delphi exceptions off:

goto Tools-Debugger Options- Language Exceptions - Turn off stop on delphi exceptions

Regards,

Hypoviax
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question