Reputation: 715
Before anyone tells me - I know the usual barriers to this problem, especially with Windows 7 and the like. You can't easily make a service application and include a user interface within it.
The fact remains, however, that some applications do something that looks suspiciously like that. Virus killers for example. Most have a service component, and usually some kind of driver component, and a user interface. The user interface tells you when you have a virus.
That's great. I've got a service that does some data processing and may need to alert the user of problems with the data. I'm using WCF so the service I've written can communicate with a Windows Forms application I've also written. The Forms app just pops up a notification area balloon thing when the service tells it to.
But what happens if the user closes the forms application? Let me go back to the virus killer analogy. What happens if a user closes the UI portion of antivirus software? Does the antivirus stop notifying the user if it detects a virus? I can't believe that to be the case.
What I want to know is this - is there a way I can have my Forms application restart if a user closes it, either by accident or deliberately? I've come up with two ways in my head.
Have another application which checks if the forms application is running. But what if both are closed? Another application to check the status of that? And another to check the status of that? I think not :)
Have the service check the sessions and start the Forms app in an appropriate session as the interactively logged on user. Unreliable. What if it's a terminal server?
It's not a massive hurdle. If the user closes the forms application, then it's their own fault if they don't get data processing alerts. But I would like to do what I can to prevent them from messing everything up.
So, any ideas?
Upvotes: 1
Views: 267
Reputation:
I think you've done enough, honestly. You can never prevent the user from messing up. If they close your UI, they don't get alerts. That should be obvious. If you really do want to restart your process though, go with your second idea of having the service start your UI app under the appropriate session. It isn't that hard to do, and a bit of Google will get you the answer. Use Cassia to query the running sessions if you are concerned about terminal services.
Upvotes: 1