开发者

Controlling a service through a separate application

I'm writing a windows service to do some daily processing, and I want to have a user-friendly way to interact with it. I'll just be doing basic things like checking its status and viewing logs, though I may decide I want to throw in a function call or two as well. After doing some research, it sounds like 开发者_JAVA百科I need a separate application to perform these functions, since the service will run independently of any user that's logged into the host machine. My idea is to have this application interact with the service through some kind of interface, but I'm not sure where to begin.

What would be the simplest way to have an application communicate with a separate service? Would I use COM, WCF, a message queue, or something else entirely? I know there are probably a few ways to do this, so I would love to hear some pros and cons if possible.

Edit: The service and the application will both be running on the same machine.


Use WCF with NetNamedPipeBinding (allows only IPC on the same machine) or .NET Remoting. If you want to do it quickly choose the technology you are more familiar with. If you are not familiar with any of these technologies choose WCF because it is newer one and you will more probably use it again in the future - so exeprience with it will be useful.


Ideally you would create a separate application and use WCF to communicate between your service and this application.

But there is a 'cheaper' way which is to implement your own simple Web server using HttpListener. See http://msdn.microsoft.com/en-us/magazine/cc163879.aspx

This makes it easy to accept a few simple commands and you can send them using any web browser.

For viewing logs why not just tail the log files (using e.g. baretail)?


Skip WCF, and just use plain .NET Remoting. So much easier. Why they call it deprecated, God knows.

Edit: Seeing it runs on the same PC, the transport would be Named Pipes, IIRC WCF supports this too.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜