rwhitaker
asked on
Using BeginThread... How do I use EndThread? Do i need to?
We are using multiple threads in our company for the first time. We understand them enough to be dangerous. Lol. What I need to know is if I am calling BeginThread and it kicks off my variable procedure, without calling EndThread, am I opening myself up to memoryleaks, etc.??? I watch all the threads in the debugger and it creates the thread and then magically ends. I believe it ends when the variable procedure ends. If I do need to call EndThread, then where do I call it at?
Here is a snipet of code.....
// -------------------------- ---------- ---------- ---------- ---------- ----- //
// procedure : PingContinualEquipment
// author : jjs
// date : 04/01
// description : Ping the equipment in the memtable every 10 seconds
// modifications :
// -------------------------- ---------- ---------- ---------- ---------- ----- //
procedure TfrmPingContinually.PingCo ntinualEqu ipment(Sen der: TObject; Handle: Integer;
Interval: Cardinal; ElapsedTime: Integer);
begin
PingThreadHandle := BeginThread(nil, 0, @PingEquipmentInList, nil, 0, PingThread);
end;
PingEquipmentInList is a variable procedure, which just pings some equipment, but does nothing to end the thread. It also doesn?t touch any variables used by any other threads or procedures, so it is kinda isolated on its own island. No need to resync.
Rick Whitaker
Iowa Glass Depot
Here is a snipet of code.....
// --------------------------
// procedure : PingContinualEquipment
// author : jjs
// date : 04/01
// description : Ping the equipment in the memtable every 10 seconds
// modifications :
// --------------------------
procedure TfrmPingContinually.PingCo
Interval: Cardinal; ElapsedTime: Integer);
begin
PingThreadHandle := BeginThread(nil, 0, @PingEquipmentInList, nil, 0, PingThread);
end;
PingEquipmentInList is a variable procedure, which just pings some equipment, but does nothing to end the thread. It also doesn?t touch any variables used by any other threads or procedures, so it is kinda isolated on its own island. No need to resync.
Rick Whitaker
Iowa Glass Depot
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
P.S: If you have any further questions about threads, just ask. My answer just seems a bit short for 200 points, but I don't know what else to say - it's really this easy... :-)
ASKER
No more questions at this time. I was just wanting to make sure I didn't have any memory leaks that would eventually smoke our citrix/Win 2000 servers.
I am just trying to get you closer to the top of the points standings... lol
Thanks again...
Rick
I am just trying to get you closer to the top of the points standings... lol
Thanks again...
Rick
:-)