?
Solved

closing threads

Posted on 2003-11-24
6
Medium Priority
?
1,025 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month12 days, 3 hours left to enroll

752 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