开发者

Will Windows wait for my service on startup?

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 OnSta开发者_如何学JAVArt 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?


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜