There is no relationship between Threads in .NET. However, there is a parent-child relationship in .NET 4's Task
/Task<T>
classes, which are, in many ways, a better approach to concurrency than directly using threads.
That being said...
I urgently need to get the parent thread from the actual thread and there is no way to hand-over this piece of information.
The main way to "hand off" information to a thread would be to implement a SynchronizationContext. This is typically done by user interface frameworks in order to implement ISynchronizeInvoke on objects within that thread (ie: Control.Invoke
). This is not something typically done manually, and requires a very customized thread that maintains it's own messaging pump or process queue which is continually being processed.
I would recommend considering changing this to a producer/consumer scenario instead, and having your "child" thread poll for new processing items. This eliminates all need to know about "parents" - since any thread can add to the processing queue. The BlockingCollection<T>
class is ideal for this scenario.