mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-26 20:00:16 +08:00
Add Plinkremote unit as a preparation for a better integration of plink.exe into our SSH tunnel.
See * http://www.delphipraxis.net/70989-komponente-fuer-ssh-verbindung-6.html * http://www.heidisql.com/forum.php?t=15206 * issue #2902
This commit is contained in:
63
source/UPipeThread.pas
Normal file
63
source/UPipeThread.pas
Normal file
@ -0,0 +1,63 @@
|
||||
unit UPipeThread;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Classes;
|
||||
|
||||
type
|
||||
TPipeThread = class(TThread)
|
||||
private
|
||||
FReadPipeData: TThreadMethod;
|
||||
FProcessHandle: THandle;
|
||||
FWillSuspend : Boolean;
|
||||
protected
|
||||
procedure Execute; override;
|
||||
public
|
||||
procedure Resume; reintroduce;
|
||||
property ProcessHandle : THandle
|
||||
read FProcessHandle write FProcessHandle;
|
||||
property ReadPipeData: TThreadMethod
|
||||
read FReadPipeData write FReadPipeData;
|
||||
property WillSuspend : Boolean
|
||||
read FWillSuspend write FWillSuspend;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ Wichtig: Methoden und Eigenschaften von Objekten in visuellen Komponenten d<>rfen
|
||||
nur in einer Methode namens Synchronize aufgerufen werden, z.B.
|
||||
|
||||
Synchronize(UpdateCaption);
|
||||
|
||||
und UpdateCaption k<>nnte folgenderma<6D>en aussehen:
|
||||
|
||||
procedure TPipeThread.UpdateCaption;
|
||||
begin
|
||||
Form1.Caption := 'Aktualisiert in einem Thread';
|
||||
end; }
|
||||
|
||||
{ TPipeThread }
|
||||
|
||||
procedure TPipeThread.Execute;
|
||||
begin
|
||||
FWillSuspend := false;
|
||||
while (WaitForSingleObject(ProcessHandle,1) <> WAIT_OBJECT_0)
|
||||
and not Terminated do
|
||||
begin
|
||||
if Assigned(FReadPipeData) then
|
||||
Synchronize(FReadPipeData);
|
||||
if FWillSuspend then
|
||||
Suspend
|
||||
else
|
||||
Sleep(1);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TPipeThread.Resume;
|
||||
begin
|
||||
FWillSuspend := false;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user