3

I need to build a small C# application which measures start up times for a definable application. I have found this free tool:

http://www.passmark.com/products/apptimer.htm

Which does exactly what I need, but I've been asked to create a more company specific internal version as we require database logging and a few other things.

I understand how to replicate all of the features except for "Input Idle". I have attempted to search for this term, but I've not found any useful references. Can anyone point me in the right direction for checking an applications "Input Idle" state?

Dan
  • 1,958
  • 1
  • 18
  • 26

3 Answers3

6

You can call

WaitForInputIdle( ProcessInfo.hProcess, INFINITE );

Waits until the specified process has finished processing its initial input and is waiting for user input with no input pending, or until the time-out interval has elapsed.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms687022(v=vs.85).aspx

http://www.codeproject.com/Articles/137/Sending-a-message-to-the-Main-Frame-Window-of-Anot

Eric J.
  • 147,927
  • 63
  • 340
  • 553
  • Excellent, that looks like it exactly. – Dan Jan 09 '13 at 17:01
  • @EtherDragon There is a minimum time limit which hadn't been met at first. I've marked the other answer purely because the user is lower rep and the answers were posted simultaneously. – Dan Jan 09 '13 at 18:53
6

It's referring to the Windows WaitForInputIdle API, which calls you back when an applicaiton has gone into an idle message loop state:

http://blogs.msdn.com/b/oldnewthing/archive/2010/03/25/9984720.aspx

jlew
  • 10,491
  • 1
  • 35
  • 58
4

System.Diagnostics has a method called Process.WaitForInputIdle() which will check if a process is idle.

Note: This will only work for programs with some sort of interface though (and a message loop).

MSDN for WaitForInoutIdle()

Check this previous question for a good example to get your started - all you'd need to do is add the idle method, and hook up the target process:

Also check this for some good suggestions on how to actually check if the target application has an interface. You will probably not need this though, since you are likely working with known applications.

Community
  • 1
  • 1
Ray
  • 1,422
  • 2
  • 21
  • 39