如何获取当前线程的 PrivilegedProcessorTime 和 UserProcessorTime
我找到了几个有关如何获取进程和所有线程的 PrivilegedProcessorTime 和 UserProcessorTime 的示例,但是如何获取当前托管线程的 PrivilegedProcessorTime 和 UserProcessorTime。
private void button1_Click(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(WorkCore));
}
static void WorkCore(Object stateInfo)
{
// Code to get and do work
// Code to get and log PrivilegedProcessorTime and UserProcessorTime
}
I found several examples of how to get the PrivilegedProcessorTime and UserProcessorTime for a process and for all threads, but how do I get the PrivilegedProcessorTime and UserProcessorTime for the current managed thread.
private void button1_Click(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(WorkCore));
}
static void WorkCore(Object stateInfo)
{
// Code to get and do work
// Code to get and log PrivilegedProcessorTime and UserProcessorTime
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我让它工作,但 AppDomain.GetCurrentThreadId 已被弃用
I got this to work but AppDomain.GetCurrentThreadId has been deprecated