Class TConsoleWatcher

Unit

Declaration

type TConsoleWatcher = class(TThread)

Description

This class aims to run an application that can run indefinitely. This execution takes place through a specific thread, allowing the main application to perform other tasks in the meantime. It is possible to interrupt its execution at any time through the Stop method. It is also possible to obtain the output generated by the application using the GetMessage command.

Hierarchy

Overview

Methods

Public constructor Create(const AProgram: string; AParams: TArray<string>);
Public destructor Destroy; override;
Public procedure Execute; override;
Public procedure Stop;
Public function GetMessage: string;

Properties

Public property IsRunning: Boolean read FIsRunning;
Public property Executed: Boolean read FExecuted;

Description

Methods

Public constructor Create(const AProgram: string; AParams: TArray<string>);

Class constructor that initialize the thread as suspended, initialize some internal fields. It is necessary to call the Start method to run the thread which in turn executes the program passed as a parameter.

Parameters
AProgram
Program name or command to be executed.
AParams
Array of argumentos to be passed to the program or command being called
Public destructor Destroy; override;

Class destructor that release resources allocate by the class.

Public procedure Execute; override;

Executes the main loop of the thread running the program passed to the class's constructor, waiting until its completion or until the Stop method is called. During program execution, its output is captured by the thread and stored in an internal field, this value can be extracted by the GetMessage function.

Public procedure Stop;

It interrupts the execution of the thread and changes the value of the IsRunning property accordingly, in addition to interrupting the execution of the program passed as a parameter to the class constructor if it is running.

Public function GetMessage: string;

Returns the output of the program being executed and clears the current content of this message, so if it is called again its content will not be the same.

Properties

Public property IsRunning: Boolean read FIsRunning;

Indicates that the thread is still running waiting for the program to finish.

Public property Executed: Boolean read FExecuted;

Indicates that the command was executed.


Generated by PasDoc 0.16.0.