如何检查winsows 2000服务器机器中的线程状态 [英] how to check the thread status in winsows 2000 server machine

查看:78
本文介绍了如何检查winsows 2000服务器机器中的线程状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用vs 2008中的代码。

我启动了线程。

如何检查该线程的状态是否存活。

i am doing the code in vs 2008.
I launched the thread .
how to check the status of that thread its alive or not.

推荐答案

一般来说,你不能。创建线程时,Windows返回线程的句柄。您可以使用该句柄执行各种查询,例如GetThreadId。如果成功,显然有一些线程与该句柄。但是随着线程句柄在一段时间后被重用,你通常不会说那是你正在寻找的线程。另一方面,在大多数情况下,这种方法会成功,因为句柄值只会在相对较长的时间后重复使用。
Generally speaking you can''t. When creating a thread, Windows returns a handle to the thread. You can do all sorts of queries using that handle, for example GetThreadId. If that succeeds, there is obviously some thread around with that handle. But as thread handles are being reused after some time, you can in general not say if that''s the thread you were looking for. On the other hand, in most cases that approach will succeed as the handle value will only be reused after a relatively long time.


如果你登录到那台机器,那么你总是可以打开任务管理器,看看你的线程是否出现在进程窗口中。

除此之外,你可以使用nv3发布的方法,因为它是一种基于声音代码的方式来处理这个问题。 br />


如果你的场景类似于一个基于服务的应用程序必须始终运行并重新启动的情况,如果不是,那么你应该将它设置为Windows Service Application并将其设置为在服务管理单元(services.msc)的恢复选项卡上重新启动
If you are logged into that machine, then you can always open the Task Manager and see if your thread appears in the processes window.
Other than that, you can use the approach that nv3 has posted as it is a sound code-based way to deal with this.

If your scenario is similar to one where you have a service based application that MUST always be running and restarted if it is not, then you should set it up as a Windows Service Application and set it to restart on the Recovery tabin the Services snap-in (services.msc)


这篇关于如何检查winsows 2000服务器机器中的线程状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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