且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使一个.NET Windows服务检测登录,注销和切换用户的事件?

更新时间:2023-12-02 15:09:46

如果你正在做一个服务,您的类是从 ServiceBase 衍生>。考虑调查 OnSessionChange 方法。重写此方法来检测不同类型的会议上改变。它提供了用于会话变化的原因,并在新的会话标识符。请务必在构造函数来设置 CanHandleSessionChangeEvent 真正,否则你的倍率不会被调用。

If you're making a service, your class is derived from ServiceBase. Consider investigating the OnSessionChange method. Override this method to detect different types of session changes. It provides both a reason for the session change, and the new session identifier. Be sure in your constructor to set CanHandleSessionChangeEvent to true, otherwise your override will not be called.