Click to See Complete Forum and Search --> : Has somebody made a surveillance thread which doesn't die?


lagu2653
October 25th, 2007, 07:33 AM
I have a log-in window application. When the user presses the cancel button it kills another window by it's name and then it exits. The problem is that if somebody kills the log-in window by terminating the process in the task manager the other window is not killed.

One solution might be to have a surveillande thread which doesn't die when the mother-thread dies, and can't be killed in the task manager. As soon as the log-in window thread stops responding to surveillance messages it will kill the other window and then exit.

Is this possible?

I've also tried to have a form which spawns another form, but in the Task Manager there is only one entry (PasswordDialog.exe). If you kill this process everything dies and the window which I want to kill when the log-in window dies is not killed.

boudino
October 26th, 2007, 07:56 AM
Im affraid that this is impossible. Having thread which cannot be killed by OS is nonsenc. It means, that your app would like to become more powerfull than the OS itself.

Only solution I can image now is to have separate processes, running under another account, which would control you forms. For example a windows service running under "Local System" account or any like this. Than there is good chance, that users won't be able to kill it.

torrud
October 26th, 2007, 09:40 AM
You can also build a ApplicationLoader which contains the login mechanism. If the login is successful finished it loads the real application in a new AppDomain and after the real application is started the application loader finish. If the user try to start the application you can prevent it by several ways. For instance the real application could awaiting a secret from the loader. If the secret will not be passed the application do not start. I think this is more possible then trying to control threads which is impossible because like boudino said the OS is the one and only thing which can doing this.