How do I know that the console application does not respond?

delphi package - easy access to kernel objects etc.
Post Reply
Ahell
Posts: 31
Joined: Mon Feb 07, 2011 4:54 pm

How do I know that the console application does not respond?

Post by Ahell »

Good day!

Interested in the following question:
How do I know when the console does not work?
Suppose I create a console application:

Code: Select all

program hung;

{$APPTYPE CONSOLE}

begin
  while true do;
end.
And the program is as follows:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
const
  Prc='hung.exe';
begin
  Process(Prc).ServiceProcess:=True;
  if Process(Prc).IsStillRunning then
    ListBox1.Items.Add('IsStillRunning = True')
  else
    ListBox1.Items.Add('IsStillRunning = False');

  if Process(Prc).IsStillValid then
    ListBox1.Items.Add('IsStillValid = True')
  else
    ListBox1.Items.Add('IsStillValid = False');
  if Process(Prc).IsValid then
    ListBox1.Items.Add('IsValid = True')
  else
    ListBox1.Items.Add('IsValid = False');
end;
All functions have returned result TRUE :sorry:

Generally there is a way of catching these problems? How do I know that the console application hangs (not responding)?

I have a lot of which asked this question, but I think you'll be able to answer it because I think that you are most know of these mechanisms work windows.

Thanks in advance!

P.S. Text translated by Google Translator. (Not so well know English).
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: How do I know that the console application does not resp

Post by madshi »

I don't think there's any way to know.

With a GUI application, every thread which has a visible window open needs to react to messages. Without that the windows will appear dead and the OS will consider the application "hung" (not responding). With console applications, the console window itself is handled by the OS. None of the threads of a console application is required to handle any messages. So there's no way from the outside to know whether a console application is "hung" or whether it's simply busy doing something.
Ahell
Posts: 31
Joined: Mon Feb 07, 2011 4:54 pm

Re: How do I know that the console application does not resp

Post by Ahell »

So sorry that no way to test the console application to hang.
Look for other ways to, well, or an alternative ...

Thank you for your reply.
Post Reply