views:

43

answers:

1

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?

+1  A: 

Hi Mike.

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!

CoreTech