活动线程数.. [英] The Number of live Threads..

查看:115
本文介绍了活动线程数..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向用户显示我的应用程序正在运行的线程数(位于文本框中). :sigh:
我该怎么办?

:
感谢Jimmanuel,但我应该在哪里使用此代码段显示我的线程
活泼的?

I wanna show to user the number of the threads of my Application that are running now (live in a textbox) . :sigh:
How can I do that?

:
thanks Jimmanuel but where should I use this snippet code to show my thread
lively ?

推荐答案

一种方法:
One way:
using (Process p = Process.GetCurrentProcess())
{
    MessageBox.Show(p.Threads.Count.ToString());
}


您可以使用Windows任务管理器

转到:
进程选项卡->视图->选择列...->线程数

新列将添加到进程"选项卡.此列将显示选定进程的线程数.
You can use Windows Task Manager

Goto:
Processes tab - > View - > Select Columns...-> Threads Count

New column will be added to Processes tab. This column will display a number of thread of selected process


经常更新TextBox的最简单方法是在Form中添加Windows.Forms.Timer,然后在回调函数使用我发布的代码片段更新TextBox文本,而不显示MessageBox.只需将Timer从工具箱中拖放到VS Form设计器中的Form上,然后您就可以在其中编辑Timer的属性和事件.
The easiest way to update a TextBox every so often is to add a Windows.Forms.Timer to your Form and then in the callback function use the snippet I posted to update the TextBox text instead of showing a MessageBox. Just drag and drop a Timer from the Toolbox onto your Form in the VS Form designer, and then you can edit the Timer''s properties and events from there.


这篇关于活动线程数..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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