Thema: Delphi Realtime Input? Thread?

Einzelnen Beitrag anzeigen

C.Schoch

Registriert seit: 2. Jan 2006
Ort: Wüstenrot
235 Beiträge
 
Turbo Delphi für Win32
 
#6

Re: Realtime Input? Thread?

  Alt 14. Mai 2006, 13:16
You can do this with WaitForSingleObject and an Event

Your function
Delphi-Quellcode:
procedure Haf;
var i:integer;
begin
i:=0;
repeat
//////Wait///////////////////////////////////
repeat
  WaitResult := DWORD WaitForSingleObject(HANDLE hHandle, { handle of object to wait for} DWORD dwMilliseconds    { time-out interval in milliseconds}); // for Handele use "event" and you must set an timeout that the funktion returns and Messages are viewed and worked on
  if WaitResult <> WAIT_OBJECT_0 then
  begin
    Application.ProcessMessages;
  end;
until WaitResult = WAIT_OBJECT_0;
/////////////////////////////////////////////
// here you can use reset event if you want to wait contiously
  input[i]:=Edit1.text;
  i:=i+1;
until i=3;
end;
Create the event:
Delphi-Quellcode:
procedure TForm1.FormShow(Sender: TObject);
begin
event := HANDLE CreateEvent(

    LPSECURITY_ATTRIBUTES lpEventAttributes,   // pointer to security attributes
    BOOL bManualReset,   // flag for manual-reset event
    BOOL bInitialState,   // flag for initial state
    LPCTSTR lpName    // pointer to event-object name
   );
end;
Set the event:
Delphi-Quellcode:
procedure ButtonClick;
begin
SetEvent(event)
end;
Close the event:
Delphi-Quellcode:
procedure TForm1.FormClose(Sender: TObject);
begin
 CloseHandle(event)
end;
Now a lot of Pseudocode (not tested)
for additional informatin wiew the SDK.
Tschau Christian
Das System hofft auf Besserung
[Siemens]
  Mit Zitat antworten Zitat