如何从子线程或其他线程进入父线程? [英] How do I get to the parent thread from a child thread or another thread?

查看:87
本文介绍了如何从子线程或其他线程进入父线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
.NET是否有一种获取父项的方法线程ID?

Possible Duplicate:
.NET Is there a way to get the parent thread id?

.NET中的线程之间是否有任何关系?我迫切需要从实际线程中获取父线程,并且无法移交这条信息. 有什么方法可以在.NET中或使用Win32 API获取父线程?

Is there any relationship between threads in .NET? I urgently need to get the parent thread from the actual thread and there is no way to handover this piece of information. Is there any way to get parent thread in .NET or using the Win32 API?

有没有办法从其他任何线程获取父线程?

Is there any way to get parent thread from any other thread?

推荐答案

.NET不记录线程之间的父子关系.您需要通过在创建时将父线程传递给子线程来自行跟踪这些数据.

.NET does not record parent-child relationships between threads. You will need to track this data on your own, by passing the parent thread to the child on creation.

也就是说,我无法想象您为什么需要这个.是不是 Join 还是足够好?

That said, I cannot possibly imagine why you would need this. Isn't Joining from the parent or something good enough?

我可以理解,您可能会对诸如无论如何您想做什么?"之类的问题感到沮丧. -但是通常如果您让我们知道您的真正目标是什么,我们也许能够找到您没有想到的更好的方法. :)

I can understand that you might be frustrated by questions like "What are you trying to do, anyway?" - but often times if you let us know what your true goal is we may be able to find a better way that you didn't think of. :)

这篇关于如何从子线程或其他线程进入父线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆