Named pipe (Windows) lazarus / 21-General ---------------------------------------------------------------------- pcurtis · 2021-05-28 09:25 How can I create an event  when text appears on a named pipe without constantly polling the pipe? The pipe is created by another application (MPV) and is used to pass status information. I send commands to the pipe with this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.SendCommand(sCOMMAND : string);begin  if not(Assigned(MySHELL)) then exit;   sCOMMAND:=sCOMMAND + LineEnding;   try    with TFilestream.Create('\\.\pipe\mpv-pipe', fmOpenReadWrite) do      try      WriteBuffer(sCOMMAND[1], sCOMMAND.length);      finally        Free;      end;  except    exit;  end;end;  The process is created with this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   MyShell := TProcess.Create(self);     with MyShell do       begin         Options := Options + [poUsePipes];         Executable:='mpv.exe';       ShowWindow:=swoHIDE;         Parameters.Add('--wid');         Parameters.Add(inttostr(MyPanel1.Handle));         //Parameters.Add(' --no-terminal');         Parameters.Add('--term-status-msg=');         Parameters.Add('--volume=0');         Parameters.Add('--input-ipc- server=\\.\pipe\mpv-pipe');         Parameters.Add('--osd-level=0');       Parameters.Add('--screenshot-directory=d:\Lazarus\TGen\Temp\');         Parameters.Add(AValue);         Execute;       end;  And I use a timer to poll STDOUT like this Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Timer1Timer(Sender: TObject);var  FSTDOut : TStringList;begin  Memo1.Clear;   if not Assigned(MyShell) then exit;   FSTDOut := TStringList.Create;   if MyShell.Output.NumBytesAvailable > 0 then    FSTDOut.LoadFromStream(MyShell.Output);   if FSTDOut.Text <> '' then Memo1.Lines.Add(FSTDOut.Text);   FSTDOut.Free;end; ---------------------------------------------------------------------- Remy Lebeau · 2021-05-28 16:42 Quote from: pcurtis on May 28, 2021, 11:25:50 amHow can I create an event  when text appears on a named pipe without constantly polling the pipe? Use a named pipe that supports Overlapped I/O, let the OS notify you when data is available for reading. Otherwise, move the reading to a separate thread and let it block until data is available.