如何从运行Windows服务的方法调用 [英] How to call method from running windows service

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

问题描述

我已经使用c#2005创建并启动了Windows服务Service1(exe作为MyService.exe)。
我包含了一个GetMyRandomNumber()方法,该方法返回一个随机双精度值。

I have created and started windows service Service1 (with exe as MyService.exe) using c# 2005. . I have included a method GetMyRandomNumber() that returns a random double value.

这里的问题是如何使用此运行服务以及如何调用

The problem here is how could use this running service and how could i call the method.

我尝试添加MyService.exe的引用,并以-

I have tried adding reference of MyService.exe and access the method as -

Service1 s = new Service1();
MessageBox.Show(s.GetMyRandomNumber().ToString());

但是发现未从服务的运行实例中调用该方法,即使我停止了

But found that the method is not called from the running instance of the service i.e. even though i stop the service the statements are executed.

有人可以向我解释如何从运行服务的实例中调用该方法。

Could someone explain me how can I call the method from running instance of the service.

感谢您分享宝贵的时间。

Thanks for sharing your valuable time.

推荐答案

您应该看看Remoting

You should have a look at Remoting

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

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