COM ActiveX   3GL   4GL

Windows

, . Delphi , . :
- . , , - ( , . .). . , ;
- . , , . , ( ) . , , , , ;
- . , , , , .


- , , () . , , Windows 95. () .


(Thread) - , - . () Win32 , (, ). .


32- , 16- , , .

. , 16- Windows .
- "" , . . "" , "" .
- , . . , , .
, . , .
, - , . Windows . , . , Windows .


. , BeginThread, .

, TThread.
TThread . (VCL) Delphi.
, :
- - . - 16 ( );
- , ;
- , VCL , VCL- , TMultiReadExclusive-WriteSynchronizer.
TThread classes ( 1.19):

1.19
TThread = class private
FHandle: THandle; FThreadID: THandle; FTerminated: Boolean; FSuspended: Boolean; FFreeOnTerminate: Boolean; FFinished: Boolean; FReturnValue: Integer; FOnTerminate: TNotifyEvent; Method: TThreadMethod; FSynchronizeException: TObject; procedure CallOnTerminate; function GetPriority: TThreadPriority; procedure SetPriority(Value: TThreadPriority); procedure SetSuspended(Value: Boolean); protected
procedure DoTerminate; virtual;
procedure Execute; virtual; abstract;
procedure Synchronize(Method: TThreadMethod);
property ReturnValue: Integer read FReturnValue write FReturnValue;
property Terminated: Boolean read FTerminated;
public
constructor Create(CreateSuspended: Boolean);
destructor Destroy; override;
procedure Resume;
procedure Suspend;
procedure Terminate;
function WaitFor: LongWord;
property FreeOnTerminate: Boolean read FFreeOnTerminate write FFreeOnTerminate;
property Handle: THandle read FHandle;
property Priority: TThreadPriority read GetPriority write SetPriority; property Suspended: Boolean read FSuspended write SetSuspended; property ThreadID: THandle read FThreadID;
property OnTerminate: TNotifyEvent read FOnTerminate write FQnTerminate; end;


, TThread TObject, , . Execute - , , TThread , . , - .
TThread Delphi File/New (/), (. 1.25) Thread Object ( ).
. Delphi .
. 1.25. New Items


IDE, , "" . , TMyThread.

TMyThread, , Delphi, - ( 1.20).

1.20
unit Unit2;
interface
uses
Classes; type
TMyThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;
implementation { TMyThread }
procedure TMyThread.Execute;
begin
{ Place thread code here } end;
end.


: - ;
- Execute , ;
- (, FreeOnTerminate:=True;).

, ,
. , , .

, . , - .
: - - , ; - - .
: Idle, Normal, High Realtime, 4 24. , Normal. . 1.2 . 1.2.




Idle


4

Normal

, Windows

7-9

High

, , Normal

13

Reaitime


24



Windows NT . , .

GetPrioriryClass SetPriorityClass .
(High) , , :
If not SetPriorityClass(GetCurrentProcess, HIGH_PRIORITY_CLASS) then ShowMessage (' ');


High Realtime, . . , , .

Priority. . . . 1.3.
1.3.




TpIdle

, . Windows ,

tpldle

-15

TpLowest

.

-2

Lower

. , tpLowest

-1

TpNormal

. tpNormal

0

TpHigher

.

1

TpHighest

. , tpHigher

2

TpTimeCritical

.

15




. , .

, , :
constructor TMyThread.Create(CreateSuspended: Boolean);
{
inheritedCreate(CreateSuspended);
Priority := tpldle;
}



. , . , - , . , , , . , FreeOnTerminate: true. . false, .
, Delphi . , Terminate. Terminate true, Execute:
procedure TMyThread.Execute;
begin
while not Terminated do
{ - };
end;



Win32 API TerminateThread. , , , (, ). , - . Windows 9.x , Windows NT , , . - . , , , , , . , , TerminateThread, (Dynamic Link Library, DLL), .

Delphi
.
, . Delphi Delphi File/New Application (/ ). , (Forml) (Edit), (Progress Bar) (Timer). , . 1.26.

 1.26
. 1.26.
Delphi File/New/Thread Object (// ). TThread, TMyThreadl. Delphi Unit2 . TMyThreadl public, count. :
type
TMyThreadl = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
count:integer;
end;

Execute TMyThreadl , . , count. , " ":
procedure TMyThreadl.Execute;
begin
while true do
begin
count:=random(maxint);
end;
end;

, (Progress Bar).
, Delphi TMyThread2. units prcount:
type
TMyThread2 = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
public
prcount:integer;
end;

Execute TMyThread2 , :
procedure TMyThread2.Execute;
begin
while true do
begin
prcount:=prcount+l;
if prcount>100 then prcount:=0;
end;
end;

, Delphi (Projectl, Unitl, Unit2, Unit3).
uniti private Threadl - TMyThreadl Thread2 - TMyThread2:
type
TForml = class(TForm)
ProgressBarl: TProgressBar;
Editl: TEdit;
Timerl: TTimer;
procedure FormCreate(Sender: TObject);
private
Threadl:TMyThreadl;
Thread2:TMyThread2;
public
{ Public declarations }
end;

, Form1. "" FormCreate Formi. FormCreate :
procedure TForml.FormCreate(Sender: TObject);
begin
Threadl:=TMyThreadl.Create(False);
Threadl.priority:=tpLowest;
Thread2:=TMyThread2.Create(False);
Thread2.priority:=tpNormal;
end;

Create (tpLowest tpNormal).


, Create TThread- CreateSuspended. (true, false). , (true) (false). Execute , CreateSuspended false ( ). , CreateSuspended true Resume Execute .

- uses unit1 unit2 unit3:
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Unit2, Unit3, StdCtrls, ComCtrls;

, . OnTimer, Timer1. OnTimer :
procedure TForml.TimerlTimer(Sender: TObject);
begin
editl.text:=inttostr(threadl.count);
progressbarl.position:=thread2.prcount;
end;

! , , ! , Delphi: Run/Run (/), , , ( ).
,
, , . Suspend Resume.
, - , . GetTickCount. , , Delphi, :
Var
StartTime, Summa: longint;
R: integer;
begin
StartTime:=GetTickCount;
R:=Random(MaxInt) ;
Summa:=GetTickCount - StartTime;
end;

, - , , . . . - (, Windows NT) GetThreadTimes, :
function GetThreadTimes (hThread: THandle; var IpCreationTime, IpExitTime, IpKernelTime, IpUserTime: TFileTime): BOOL; stdcall;
, :
- hThread - , ;
- IpCreationTime - ;
- lpExitTime - ( );
- lpKerneiTime - , ;
- lpUserTime - , .
. , TFiieTime:
type
TFiieTime = record
dwLowDateTime: DWORD;
dwHighDateTime: DWORD;
end;

To , TFiieTime: dwLowDateTime dwHighDateTime 64- . ( 100 ), 1 1601 .


TFiieTime Int64, : If Int64 (CreationTime) > Int64 (ExitTime) then ShowMessage(' .').

VCL-
Execute . , , : , . , . , . . , . , , , .
, , VCL .
, , , .
VCL- , . ( Execute), . :
procedure TMyThread.PushTheButton;
begin
Buttonl.Click;
end;
procedure TMyThread.Execute;
begin
...
Synchronize(PushTheButton);
...
end;

"".
"" , .


. VCL- .

, :
- (Data access) , . , Microsoft Access. Access Microsoft ADO, .


, , , , (, DataSet DataSource). .

- . , TFont, TPen, TBrush, TBitmap, TMetaf ile Ticon;
- (List), , TList - TThreadList.

, , . , , , . , , . ., , - , . . , .
, Delphi. :
- . , ;
- TThread;
- , threadvar.
, . , , .
. , . :
type
TMyThreadl = class(TThread)
private
i,j,k,1: integer; // integer
a,b,c: char; // char
end;

TThread , . . ( 10-11 ,
threadvar).
( threadvar), . , ,
. , , , ( ). Win32 API (thread-local storage). . var threadvar.

, . .

.
Win32 API , , , - , .
Win32 API:
- (critical section);
- (Events);
- (Mutex);
- (Semaphore);
- (Timer).
, , , , .

, -, Delphi .
- , .
"", , "" "". , .
TCriticaisection. , : Acquire ( Enter)
Release ( Leave).
Acquire (Enter) , , .
Release (Leave) .


, . ., , Acquire (Enter) . .

, LockXY. X Y.
LockXY.Acquire; //
try
Y := sin(X); finally
LockXY.Release;
end;

, X Y, .

. (TEvent) : .
, . .
TEvent : SetEvent, , ResetEvent, .
, waitFor:
type TWaitResult = (wrSignaled, wrTimeout, wrAbandoned, wrError); function WaitFor(Timeout: DWORD): TWaitResult;
Timeout, , . wrSignaled , , wrTimeout - . Timeout INFINITE, .
CreateEvent: CreateEvent (lpEventAttributes, bManualReset, bInitialState, lpName);
:
- IpEventAttributes - . Windows NT, NULL, , . Windows 9 ;
- bManualReset - . true, ResetEvent . false, Windows ;
- bInitialState - ( ). true, , - ;
- LpName - / . , (\). . , , . NULL, . , , , ERROR_INVALID__HANDLE.
( )
. , , . , .
.
CreateMutex!
CreateMutex (lpMutexAttributes, blnitialOwner, IpName);
:
- IpMutexAttributes - SECURITY_ATTRIBUTES, , -. Windows NT, IpMutexAttributes = NULL, , . Windows 9x ;
- blnitialOwner - . true, . , ;
- lpName - . . , (\). . , , . NULL, . , , , ERROR_INVALID_HANDLE.

, . ( ). . , , , , , - . "" .
, . , , . , , .
CreateSemaphore :
CreateSemaphore (IpSemaphoreAttributes, UnitialCount, IMaximumCount, IpName);
:
- lpSemaphoreAttributes - , Windows 9x. NULL, ;
- lInitialCount - . lMaximumCount;
- lMaximumCount - ( ). ;
- lpName - . , (\). . , . IpName NULL, . , (, , , ), GetLastError ' ERROR_INVALID_HANDLE. , . . .


.


. suspend. Resume. , . . Suspend , a Resume . , , . ., Suspend, Resume, () Resume .

, , . , - . : .
, -. , .
- , , .
, ActiveX.

  COM ActiveX   3GL   4GL

, - - , . COM, CORBA, .Net.
{DATA}




 10.11.2021 - 12:37: - Personalias -> WHO IS WHO - - _.
10.11.2021 - 12:36: - Conscience -> . ? - _.
10.11.2021 - 12:36: , , - Upbringing, Inlightening, Education -> ... - _.
10.11.2021 - 12:35: - Ecology -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> - _.
10.11.2021 - 12:34: , - War, Politics and Science -> . - _.
10.11.2021 - 12:34: , , - Upbringing, Inlightening, Education -> , - _.
10.11.2021 - 09:18: - New Technologies -> , 5G- - _.
10.11.2021 - 09:18: - Ecology -> - _.
10.11.2021 - 09:16: - Ecology -> - _.
10.11.2021 - 09:15: , , - Upbringing, Inlightening, Education -> - _.
10.11.2021 - 09:13: , , - Upbringing, Inlightening, Education -> - _.
Bourabai Research -  XXI Bourabai Research Institution