Page 1 of 1

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

PostPosted: Sun May 15, 2011 7:40 pm
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).

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

PostPosted: Mon May 16, 2011 7:35 am
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.

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

PostPosted: Mon May 16, 2011 12:30 pm
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.