Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi,

I'm trying to get parent thread name/info in child thread. I want to do that; My classes need to use parent thread info for connect to database. My application running multithread and each threads classes connecting diffrent connection string. So when my parent threads create sub thread, sub threads should use parent thread classes connection string.

How can take parent thread informations in sub threads?

Thanks,
Gökhan
Posted
Comments
Sergey Alexandrovich Kryukov 29-May-13 3:23am    
I tried to answer, but I wonder: why? Don't you think using such relationships between thread would not be a good programming practice.

Also, you should always tag your platform and language. It's really hard to try to take into account all thinkable OS. :-)

—SA
Gokhan CETIN 29-May-13 4:22am    
Yes You are right. This is not a good idea but our application is currently using. If I manage to all sql connection, we have to change all current code blocks. So I'm tring to find simple method for to do this. I thought that; If I take thread info in base class, I can manage all classes connections by using parent Thread classes connecton.

I will resource another ways.. :)

Thanks
Sergey Alexandrovich Kryukov 29-May-13 8:44am    
Not quite clear, but having some legacy code can explain many things... Thank you for answering.
—SA

1 solution

Threads don't have names. To best of my knowledge, parent-child relationships between threads are not generally preserved by the OS. They are hosted by a certain process, of course. In other words, threads of the same process are equal in their relationships, no one is known to be a parent or a child of another one. You can only preserve some relationships like that, if you actually pass some parent thread information to the child thread when you create them.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900