Solved

Resume Terminated Thread - D7

Posted on 2006-11-08
4
635 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Send message from delphi to whatsapp, is it possible? 3 1,160
Strange behavior when a form is closed 6 51
Working with hours 3 46
Multi-layered image in FireMonkey 9 16
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

910 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

25 Experts available now in Live!

Get 1:1 Help Now