Solved

Resume Terminated Thread - D7

Posted on 2006-11-08
4
638 Views
Last Modified: 2008-03-15
Hi,

I was wondering if it is possible to resume execution or re-execute a thread after it is terminated. I have used Suspend and Resume which work but they cause the program to sometimes hang unpredictably preventing my program from closing therefore I decided not to use them. I am using the thread for reading over an indy connection.

The thread object is created during application start (FormCreate) and terminated when the connection is disconnected. The thread object is not freed on termination (my choice FreeOnTerminate := False) so I guess the reference to the thread object is still valid. I would like to have just one thread on the client and I am avoiding creating the thread on each connect. I have read that the overhead in managing multiple threads can impact performance. I have also noticed I cannot free the thread object when my application is closing down (FormClose) coz it hangs on calling Free even though the thread is terminated before freeing it.
0
Comment
Question by:martbase
4 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 100 total points
ID: 17905207
Nope. Once a thread is terminated, it's resources are gone too. All you have is the handle of the terminated process which could be used to get the final status of the thread and it's exitcode. But Windows has released all (well, most) of the resources it was using.

An application that hangs is often experiencing a deadlock, where two threads are waiting for each other to release a certain resource. Sometimes one of them will time-out but I've seen plenty of situation where the thread is waiting for an infinite amount of time for a resource to be released.
0
 
LVL 17

Assisted Solution

by:TheRealLoki
TheRealLoki earned 100 total points
ID: 17909101
if your program is hangingwhen you call suspend, then it probably means your thread is not checking "If terminated" or "suspended" often enough.
Hangs are avoidable as long as you are careful
can you paste your thread's on execute loop here?
Once we find the issue, and iron it out, you can carry on with just suspend and resume
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21133162
Forced accept.

Computer101
EE Admin
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb download file link ? 1 132
How to renew a Delphi rad-studio licence? 5 63
Moving (cutting/pasting) controls in a TTabbedNotebook... 7 34
Dev express lookupcombo 3 26
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…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

813 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now