开始和终止多个过程 [英] starting and terminating multiple process

查看:101
本文介绍了开始和终止多个过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在启动服务时启动许多流程,请问有什么方法可以通过创建流程来做到这一点?在停止该服务时,我需要停止在服务启动期间启动的所有进程的所有实例.如何使用终止进程来做到这一点.

在此先感谢
Praveen

HI i need to start a number of process on starting a service,is there any way i can do that with create process? and on stopping that service i need to stop all the instances of all the process started during the start of service how can i do that with terminate process.

Thanks in advance
Praveen

推荐答案

嗨Praveen,

在服务的OnStart事件处理程序中,您将启动要启动的进程并将它们存储在适当的数据结构(例如数组)中.
然后,OnStop事件处理程序将在包含流程实例的数组上进行迭代,并为每个实例调用Kill().
确实要确保使用流程实例的HasExited属性停止检查的流程.如果您想做一些Win32 API魔术,则Handle属性为您提供该过程的本机Windows OS系统句柄.

希望对您有所帮助.

欢呼声

曼弗雷德(Manfred)
Hi Praveen,

in your services OnStart event handler you''d start the processes you want to start and store them in an appropriate data structure (an array for example).
The OnStop event handler would then iterate over the array containing the process instances and invoke Kill() for each of them.
Te be really shure the processes where stopped check with the HasExited property of the process instance. If you want do some Win32 API magic the Handle property gives you the native Windows OS system handle of the process.

Hope this helps some.

Cheers

Manfred


这篇关于开始和终止多个过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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