活动线程数.. [英] The Number of live Threads..
本文介绍了活动线程数..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想向用户显示我的应用程序正在运行的线程数(位于文本框中). :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
从工具箱中拖放到VSForm
设计器中的Form
上,然后您就可以在其中编辑Timer
的属性和事件.
The easiest way to update aTextBox
every so often is to add aWindows.Forms.Timer
to yourForm
and then in the callback function use the snippet I posted to update theTextBox
text instead of showing aMessageBox
. Just drag and drop aTimer
from the Toolbox onto yourForm
in the VSForm
designer, and then you can edit theTimer
''s properties and events from there.
这篇关于活动线程数..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文