(Csharp)需要知道哪个子线程属于哪个父线程 [英] (Csharp)need to know which child thread belong to which parent

查看:99
本文介绍了(Csharp)需要知道哪个子线程属于哪个父线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于资源监控,我需要知道正在消耗多少资源。有没有一种好方法可以知道线程所属的父级。从那里我可以记录每个线程的使用情况...



我尝试过:



我可以在线程启动时传递父ID,但是在这个成熟的项目中已经有很多其他启动线程的方法已经在使用...真的只需要在记录时知道它。 div class =h2_lin>解决方案

.NET中的线程之间没有父子关系。您必须自己设置结构和跟踪机制来完成此操作。一些方法启动线程并将数据放入结构中并在线程终止时将其删除。



我不明白为什么你需要这样做。


为什么不使用visual studio性能窗口?我无法想到在非调试版本中监视这个的任何原因。


结合者绩效分析指南 [ ^ ]


For resource monitoring i need to know how much resources are being consumed. Is there a good way to know which parent a thread belongs to. from there I can log usage per thread...

What I have tried:

I can pass the parent id in a thread start, but there are so many other way to start a thread for are already in use in this mature project... really just need to know it at logging time.

解决方案

There is no such thing as a parent-child relationship between threads in .NET. You have to setup a structure and tracking mechanism to do this yourself. Some method of launching threads and placing the data in the structure and removing it when threads terminate.

I fail to see why you would ever need to do this.


Why do you not use the visual studio performance window? I can't think of any reason of 'monitoring' this in a none-debug version.

Beginners Guide to Performance Profiling[^]


这篇关于(Csharp)需要知道哪个子线程属于哪个父线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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