SetCurrentThreadName after thread dies

Post questions here regarding the CodeSite Express edition

SetCurrentThreadName after thread dies

Postby JonRobertson » Fri Jun 14, 2013 3:41 pm

For future reference:

One thing I've noticed is that CodeSite does not "know" when a thread dies. For instance, our DataSnap service creates a new thread for each user connection. But threads are also created for other purposes, not always by code we have access to. If a thread is created and SetCurrentThreadName is not called AND the same thread ID was previously used for a named thread, CodeSite will continue using the thread name for messages on the new thread.

I'm going to ensure that any threads created by our code are named and I'm going to implement code that clears the thread name when the thread is destroyed. I've found a way to do this for any thread created by TThread, even if we did not create the thread (such as Indy threads). Call TThread.CurrentThread to receive a TThread reference to the thread, and then assign a handler to the OnTerminate event of the thread. If the thread already has an OnTerminate, you'll need to chain the events.
JonRobertson
 
Posts: 28
Joined:
Thu Sep 15, 2011 12:08 am

Re: SetCurrentThreadName after thread dies

Postby Raize Support » Sat Jun 15, 2013 12:24 am

Thanks for sharing.

Ray
Raize Software Support
Raize Software
http://www.raize.com
Raize Support
 
Posts: 603
Joined:
Fri Mar 25, 2011 9:04 pm


Return to Express Edition

Who is online

Users browsing this forum: No registered users and 1 guest

cron