简体   繁体   English

线程之间的关系(任务)

[英]Relationships between threads (tasks)

I know that there is no possibilty to distinguish any relationship between threads in the System.Thread model, but is it also not possible in the Task(Task) model?. 我知道没有可能在System.Thread模型中区分线程之间的任何关系,但是在Task(Task)模型中也不可能吗? I would like to profile a multithreaded application, the last thing I would like to do, is passing some kind of context to all my methods and threads. 我想对多线程应用程序进行概要分析,最后我想做的是将某种上下文传递给我的所有方法和线程。 I would appreciate any ideas. 我将不胜感激。 What I would like to accomplish is similar to: 我要完成的工作类似于:

  1. ThreadMain -750ms (capture method calls) ThreadMain -750ms(捕获方法调用)
    • Thread1 - 300ms (capture method calls) 线程1-300毫秒(捕获方法调用)
      • Thread11 - 99ms (capture method calls) 线程11-99毫秒(捕获方法调用)
      • Thread12 - 20ms (capture method calls) 线程12-20毫秒(捕获方法调用)
    • Thread1 - 540ms (capture method calls) 线程1-540毫秒(捕获方法调用)
      • Thread21 - 90ms (capture method calls) 线程21-90毫秒(捕获方法调用)
      • Thread22 - 60ms (capture method calls) 线程22-60毫秒(捕获方法调用)

I have an good idea of capturing the execution time using Postsharp, but I would like to find out the relationship of the parent/child threads. 我有一个使用Postsharp捕获执行时间的好主意,但我想找出父/子线程的关系。 Any ideas? 有任何想法吗?

没有这样的事情,线程是线程-它没有“父”或“子”线程的任何概念。

您可能可以按照NewThreadName.CreatedByThreadName的命名约定来命名线程,并使用System.Diagnostics.Process.Threads属性查找与该进程关联的线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM