I personally recommend the Windows implementation because you do not need to worry about all the different scenarios that might happen:
Close the application or leave it open?
What should I do if the user has an invitation (message box) displayed on the screen?
If you close the application down, how do you handle the current job?
If you do not close the application, how do you inform the user, and then if another user wants to log in, how do you gracefully roll back previous user information?
If another user wants to log in, how can you prevent them from seeing any confidential information that the previous user could leave on the screen?
However, if you want to continue this, then it is best to connect to standard message pipeline messages via IMessageFilter. Here 's a decent article on how to use it.
source share