473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Getting idle time of process.

Hi all,

I want to get idle time of process. Means time in which process is
sitting idle.

Can i do this in c#.

Because what i want is those process which are not running since say
last 10 mins kill those processes.

please help me asap.

thanks in advance.

Oct 30 '07 #1
4 6819
Killing random processes is a very, very bad idea. Also, getting the
"not running since" time is tricky, since many processes will be
semi-idle - i.e. the OS will offer them time and they will simply put
themselves back to sleep.

What are you trying to achieve here?

Marc
Oct 30 '07 #2
For a more direct answer, you can periodically query
Process.GetProcesses(), and (for each, matching presumably on .Id),
compare the .TotalProcessorTime with what it was last time you
checked, and call .Kill() for any that you don't like...

But again - don't go killing at random; many essential system
processes would (using the above) show as idle. I would say limit
yourself to apps that you know about, but even that is risky; killing
a process is very brutal. You could try CloseMainWindow() first, but
to be honest I don't like the sound of this entire concept...
Processes should shut themselves down cleanly when they are happy
to...

Marc
Oct 30 '07 #3
Hello archana,

just to add to Mark's post, you can use Application.Idle for Winforms projecs

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
aHi all,
a>
aI want to get idle time of process. Means time in which process is
asitting idle.
a>
aCan i do this in c#.
a>
aBecause what i want is those process which are not running since say
alast 10 mins kill those processes.
a>
aplease help me asap.
a>
athanks in advance.
a>
Oct 30 '07 #4
you can use Application.Idle for Winforms projecs

Application.Idle is for the /current/ process, but given the talk of
processes, I assume that we are talking out-of-process, so this
probably won't do quite what the OP requires.

Marc
Oct 30 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: Kerry Neilson | last post by:
For the past couple of months, Idle won't start when I invoke it. I am at a complete loss for why this is. When this happens, they python command line still starts, and python works fine...
17
by: los | last post by:
Hi, I'm trying to create a program similar to that of Google's desktop that will crawl through the hard drive and index files. I have written the program and as of now I just put the thread to...
3
by: john | last post by:
I don't want to know what the CPU utilization is right now. I want to get the average utilization over the last, for example, hour. So I came up with a method where I would get a Process object...
19
by: Frank Rizzo | last post by:
I want to log the user out when there has been a period of inactivity in the application. The key here is inactivity of the application, not the system. I know that you can retrieve the...
3
by: Jim G | last post by:
Hi, We have a limited number of licenses to some software we have installed on our users desktops. The problem is that sometimes the users open up the application and then don't use it all day....
7
by: iwdu15 | last post by:
how can i tell if my system has gone idle? then how can i execute a command accordingly? thnks
8
by: Stefan Barlow | last post by:
On IIS 6, I've disabled idle timeouts and any app pool recycling other than the 29 hour timed recycle. I've disabled both on the app pool itself and on all app pools at the server level. I've...
33
by: ram.ragu | last post by:
hi i have problem to calculate idle time of cpu and if idle time is more then i have to shut down the system. can anyone tell me the idea to so that please
6
by: TyBreaker | last post by:
I am using a performance counter to record the "Elapsed (CPU) time" of the "Idle" process. I record the elapsed time, wait 1 second and then record the new elapsed time. The result I get is: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.