C#远程服务器服务交互 [英] C# Remote Server Service Interaction

查看:154
本文介绍了C#远程服务器服务交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台服务器上运行着一项服务,该服务监视目录中的文件计数.如果文件计数达到一定阈值,则我的服务会向我们的帮助台发送一封电子邮件,提醒他们这一事实,但还会尝试停止并重新启动本应获取这些文件的远程计算机上的Windows服务.我遇到的问题是,对于我尝试与之交互的远程计算机服务,ServiceController Status有时不时返回Stopped,并且当我尝试再次启动该服务时,我得到一个错误,指出该服务的实例已在运行.有人知道我为什么会得到错误的停止状态吗?

Hi, I have a service running on one server that monitors directories for file counts. If the file count reaches a certain threshold then my service sends our help desk an email alerting them of this fact, but also tries to stop and restart the Windows service on a remote machine that is supposed to be picking up those files. The issue I am having is that every now and then the ServiceController Status returns Stopped for the Remote Machine service I am trying to interact with and when I try to start the service again I get an error that An Instance of the service is already running. Does anyone know why I would get a false status of stopped?

推荐答案

实际上我认为我找到了答案.在轮询例程中,我需要在服务控制器上调用refresh方法,以确保刷新状态,否则无论最后的状态如何,它都保持不变.

谢谢
Actually I think I found the answer. In the polling routine I needed to call the refresh method on the service controller to make sure the status refreshed otherwise it remained whatever the last status was.

Thanks
Ray


这篇关于C#远程服务器服务交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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