Windows 会在启动时等待我的服务吗?
我已经编写了一个要自动启动的服务。它在其 OnStart 方法中执行一些初始化操作,包括为登录者设置 SENS 观察程序。Windows
是否会等到我的 OnStart 方法完成后才允许用户登录,或者是否有可能在我的观察程序之前发生此类登录设置完毕后,如果用户移动得足够快?
如果后者是真的,任何人都可以推荐一种方法来确保这种情况不会发生吗?
I've written a service that is to be started automatically. It does some initialization stuff in its OnStart method, including setting up SENS watchers for who logs in.
Will Windows wait until my OnStart method is complete before it allows uers to log in, or is it possible that such a login could happen before my watchers are set up, if the user moves quickly enough?
If the latter is true, can anyone recommend a way to ensure this doesn't happen?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,您的服务是与其他启动活动并行启动的,并且不能保证 OnStart() 将在有人登录之前完成。如果 OnStart() 执行非常冗长的操作,则尤其如此,但如果 OnStart() 执行,则不必担心() 很快完成。
也许您可以构建您的代码,以便不在 OnStart() 中执行太多操作,甚至更好的是,在有人登录后对启动做出适当的反应?
祝你好运!
Unfortunately your service is started in parallel with other bootup activities and there is no guarantee that OnStart() will complete prior to someone logging in. This is especially true if OnStart() executes a very lengthy operation, but is not a practical worry if OnStart() completes quickly.
Perhaps you can structure your code to not do too much in OnStart(), and even better, react appropriately to being started after someone has already logged on?
Good luck!