开发者

Need suggestion on replacing Windows Service by invisible WinForm Application

开发者 https://www.devze.com 2023-02-07 12:31 出处:网络
I need a background application to support my client application, which should always run on the client machine regardless of the main client application is running or not.

I need a background application to support my client application, which should always run on the client machine regardless of the main client application is running or not.

Windows Service was my first choice but problems I faced with Windows Service were: ease of control over windows service through main client application, release and installation of patches to the windows service and troubleshooting if windows service fails to run.

So, I started thinking for alternatives to the Windows Service and found that a Wi开发者_如何学运维ndows Forms application with NO visible forms can do it for me. This invisible app should start with system startup and keep running all the time, doing all the work that a Windows Service would do. But before I go deeper into the development, I want to explore the pros and cons of this approach.

Any suggestions/comments on this approach?


Your requirements are more suited for windows service. Main advantage with windows service is that it will start as soon as system comes up, irrespective of anybody is logged into system or not.

To sort out deployment issues, you build your business logic into separate assembly and call the necessary function withing windows service. This way you can deploy just the modified assembly.

Winform application with invisible form will not serve the purpose. HTH


That's not possible. User-mode applications must be started by a user, and will not continue to run when that user logs off. That's the purpose of the SessionEnding event: to allow you to shut down your app gracefully when the user logs off or the computer is shutting down. You can't just start something at system startup and keep it running all the time.

You need a Windows Service for that. But you should be aware that under Windows Vista and later, a service cannot interact directly with the user. They run in a separate process and are restricted from displaying their own UI. It's not clear from the question exactly what your needs are, but this is an important limitation of a Windows Service that is worth considering. A proper design really shouldn't require this, but there are apparently a lot of people to whom this new, more secure behavior is a real surprise. I explain this in more detail in related answers to this question and this other question.

0

精彩评论

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