tags:

views:

273

answers:

4

Hi,

I am writing an application that runs on Windows logon but I want it to wait until the desktop is fully functional/loaded before it actually starts doing anything. Is there any way of working out when Windows has completely finished loading the desktop?

A: 

Just install your application into the startup folder. Also look at the wikipedia page on startup. To install a C# application in the startup folder read this.

Lucas McCoy
The starting of the application isn't the issue. It's ensuring that everything else is loaded and done before I actually start doing any work in my application. I was thinking along the lines of monitoring cpu activity, but this doesn't seem a very nice way to do it.
Ataris22
**@Ataris22:** Monitoring the CPU activity wouldn't work because some older systems always run at about 80%-100% usage. The last link explains how to do what you want.
Lucas McCoy
Again, it is not the starting of the application that I am struggling with. The application is already using the registry key mentioned in the above link. The question is regarding how to best tell that the Windows desktop is in a completely functional state (not something that setting it to run at startup will achieve by itself)
Ataris22
Please clarify your definition of "completely functional". What criteria would you use to determine this?
Matt
@Matthew I believe he was looking for suggests as to that very question...
ShuggyCoUk
Yep, that was the very question. I understand it is a pretty awkward question. Thanks for everyones input.
Ataris22
+3  A: 

On vista you could use a service in Automatic (Delayed) mode, this would start before log on if no one logged on fast enough though but if you wished to avoid running until much of the system had become ready this would work. If you are heavily user centric in your desire to wait till they are ready then you will likely have to use user centric triggers.

Several metrics exist which would give you a good idea of whether the user considered the session ready for use:

  • CPU load of processes associated with the System account were no longer taking a significant proportion of the CPU time.
  • The user has begun interacting with the UI (so significant mouse movement or keyboard activity)
  • network connectivity is established

Since these are heuristics you should have some time based constraints for the minimum and maximum possible wait in case they misfire.

ShuggyCoUk
Thanks, this is the kind of thing that I was after. I am thinking Performance counters might be a place to start looking in terms of this. The system is automated so there will be no user interaction to monitor but there must be other things that give a good indication that it has finished doing it's bits and bobs. Will get digging.
Ataris22
Ataris22 - I'd still be interested to know the ultimate effect you're looking to achieve, e.g. what will your application do such that you want it to load late (last) in the startup process?
Matt
+2  A: 

I assume you're primarily referring to interactive UI-based apps and not system services.

There's no way to know when the other applications have finished loading, since the definition of "finished" isn't clear cut. However you can control the startup order of applications using a third party utility such as http://www.chameleon-managers.com/windows-startup-manager/startup-delayer.php.

I'm curious to understand what effect you're trying to achieve by having your application run only after the other desktop applications have completed loading. Knowing this might help to suggest alternative answers.

Regards

Matt
A: 

In the load of your application couldn't you enter into a timer loop and wait until all your prerequisite processes are loaded by monitering the process list. Once conditions are satisfied then you could continue with initializing your application.

Process[] apps  =   Process.GetProcesses();
Brad
You make a good point - if you explicitly know what you're waiting for, you can code for that.
Matt