.net - Detect the application active time (after Application.Idle) -
i want simple method check when application busy , when idle. after doing searching found 2 ways people have suggested. 1 getlastinputinfo function , other application.idle.
i want detect application inactivity not system inactivity. planning use application.idle. how trigger event when application becomes active again? starting timer in idle event , wish reset in other function.
any appreciated.
my event handler:
void application_idle(object sender, eventargs e) { system.timers.timer atimer = new system.timers.timer(5000); atimer.elapsed += atimer_elapsed; atimer.enabled = true; }
consider using imessagefilter.prefiltermessage method ui event "wakes" application idle. example below application wrote in vb, principle same.
you can filter messages determine actions mean "wake", instance mouse on count? or mouse clicks , key presses?
dim mf new messagefilter application.addmessagefilter(mf) ... imports system.security.permissions public class messagefilter implements imessagefilter <securitypermission(securityaction.linkdemand, flags:=securitypermissionflag.unmanagedcode)> public function prefiltermessage(byref m system.windows.forms.message) boolean implements imessagefilter.prefiltermessage ' optional code here determine events mean wake ' code here turn timer off ' return false allow message pass return false end function end class
Comments
Post a Comment