I am looking for a way to determine for a thread on which other thread it was originally spawned. I do not know whether a mechanism exists to do this, similar to the “Parent” property on Tasks in the new Task Parallel Library for .NET 4
Edit:
Further investigation actually seems to indicate that there is no location to store this information, so short of really ugly hacks this does not appear to be possible to implement transparently.
As such I think I will accept the sample code below as the most feasible (non-transparent) answer to solve the problem, even though I’ll have to look for an alternate design myself. Thanks 🙂
The system doesn’t provide such functionality internally. You can pass the thread ID of the parent thread to the thread start function pretty easily: