Broker:
set MAVEN_OPTS=-Xmx256m -XX:MaxPermSize=64m -DisDevMachine=true
open file dialog in inno setup
free theora player - use ffmpeg2theora to convert
I wound up using a two-step detection process:
- Hook into the
System.Windows.Forms.Application.Idleevent to help detect when the user is idle. Note, I said help .... - If the user is idle, use
System.Diagnostics.Process.GetCurrentProcess().TotalProcessorTimeto determine if the CPU is idle (at least for this process).
I also had to add a third component, a timer, in order to continue detecting idle state. I found that while an application has focus, it seems to get a "pulse" (in the form of an Application.Idle event) once a second, even if there are no timers in the application. However, once a different application gets focus, the background app no longer gets that pulse. If I dig around, I would expect to find that Windows� is sending a system clock update to whichever application has focus. Regardless of its origin, I needed to give the class its own "heartbeat" so it would continue to operate as a background application.
Using the code
The main code is in the static class ApplicationIdleTimer.
public static event ApplicationIdle;
This static event is what you would normally use to listen for idleness. When the application is determined to be idle, you will receive an event containing an ApplicationIdleEventArgs which tells you:
DateTime IdleSince: the time the application became idle.TimeSpan IdleDuration: the length of time the application has been i