从另一个Windows服务调用Windows服务 [英] Call windows service from another windows service

查看:87
本文介绍了从另一个Windows服务调用Windows服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在C#中从另一个Windows服务调用Windows服务?我创建了两个Windows服务WindowsService1WindowsService2.我想在WindowsService1中调用WindowsService2,这意味着将一个Windows服务调用到另一个Windows服务.请给我一个解决方案.

Is it possible to call windows service from another windows service in C#? I have created two windows services WindowsService1 and WindowsService2. I want to call WindowsService2 in WindowsService1, means call one windows service to another windows service. Please give me a solution.

推荐答案

是的.请参见 ServiceController类 [
Yes. See the ServiceController class[^] - it contains an example.


您不呼叫"服务.您可以控制它(启动,停止,暂停,继续和自定义命令),但是不能调用它.

正如Griff所说的,ServiceController对象就是您要使用的对象.
You don''t "call" a service. You can control it (start, stop, pause, resume, and custom commands), but you can''t call it.

As Griff has already stated, the ServiceController object is what you want to use.


如果您需要调用另一个服务中的功能,则必须为该服务设置一个消息传递系统,通常是TCP连接.
If you need to call the functionality within another service you have to setup a messaging system for that service, usually TCP connections.


这篇关于从另一个Windows服务调用Windows服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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