开发者

How to exit a process from Window Service in C#

I have two processes both developed in C#.

One of them is a Windows Service, the other one a normal windows based application.

What I intend to do is to exit the 开发者_开发技巧application from Service,

I don't intend to kill it forcibly, which i am able to do. I want to exit it gracefully.

Can i call the application_close function defined in my application through the service.


Process.CloseMainWindow() is what you're looking for, I believe.

http://msdn.microsoft.com/en-us/library/system.diagnostics.process.closemainwindow.aspx

Edit: If you really want to implement IPC, I've found utilizing message queues to be the most easily-implemented solution in windows, but even that isn't very simple, and I wouldn't recommend it when all you want is resource cleanup on exit.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜