Answer the question
In order to leave comments, you need to log in
How to programmatically monitor the state of any application in Windows OS?
In Windows OS, in the Task Manager on the "Applications" tab, we can see the status of the application (Working / Not responding). How can we programmatically monitor this state?
Answer the question
In order to leave comments, you need to log in
ProcessStartInfo psiOpt = new ProcessStartInfo(@"cmd.exe", @"/C tasklist /fi ""imagename eq notepad*"" /fi ""status eq not responding"" ");
psiOpt.WindowStyle = ProcessWindowStyle.Hidden;
psiOpt.StandardOutputEncoding = Encoding.GetEncoding(866);
psiOpt.RedirectStandardOutput = true;
psiOpt.UseShellExecute = false;
psiOpt.CreateNoWindow = true;
Process procCommand = Process.Start(psiOpt);
StreamReader srIncoming = procCommand.StandardOutput;
label1.Text = srIncoming.ReadToEnd().ToString();
procCommand.Close();
Not sure, but you can try message queue. The task manager gets the queue of applications by redrawing and sees how quickly they disappear from there. If the application is not a GUI, then it is unlikely that it will be possible to track it somehow. Such an application can work in the background, wait for an event, can respond to commands sent via a socket, and much more (the OS does not send any events). But if the GUI, then windows that are not redrawn can somehow be caught. Either through the GUI, through the messages, some information is trying to be read.
In general, it is better to study the structure of the application and understand what files and how it consumes memory during operation.
If memory is not consumed or messages are not written to the file, then such an application could freeze ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question