title: Overbyte NamedPipes; Send msg on a different thread
body: <p>I'm fairly new to IPC(interprocess communication). Doing my research, I decided on the Named pipes.<br>
  My application consists of 2 parts: a monitoring app, and a UI dashboard. The dashboard receives updates from the monitor constantly and shows stats, the user should be able to change certain parameters of the monitor through the dashboard (refresh rate, restart process,scheduled task...) so it has to be a bidirectional communication. The Monitor would later become a service application, but that's a plan for later.<br>
  Getting to the point, I used the Pipes unit by Overbyte(Francois Piette) v1.01
  and followed the example made on their <a href="http://www.overbyte.be/eng/download.html?url=http://www.overbyte.be/arch/IpcUsingPipes.zip" rel="nofollow noreferrer">website</a>. When connecting the pipes on the main thread, it functions normally. But due to my monitor needing a separate thread to (monitor-send message-sleep-loop...), when I try to connect on the other thread, I get an error <strong>"The notify window and the component window do not exist in the same thread!"</strong><br></p>
  
  <ul>
  <li>What I need to know is, can named pipes communicate using a separate thread? (Judging by the error msg, I feel it may be fetching the window handle on the main UI and would not work on a different thread)</li>
  <li>Is there a better way to implement my application? or named pipes better than Overbyte?</li>
  </ul>
  
  <p>Sample of my code:</p>
  
  <pre><code>TThreadMonitor = Class(TThread)
    private
      PipeClient1: TPipeClient;
      listOfProcesses: Array of String;
    protected
      procedure Execute; override;
    public
      constructor Create(CreateSuspended: Boolean);
  
      procedure ConnectPipe;
      procedure SendMessage(const Msg: String);
    End;
  
  var
  t: TThreadMonitor;
  
  procedure TClientFormMain.BtnDifferentThreadClick(Sender: TObject);
  begin
    t := TThreadMonitor.Create(TRUE);
    t.FreeOnTerminate := TRUE;
  
    t.Start;
  end;
  
  procedure TThreadMonitor.ConnectPipe;
  begin
    if not PipeClient1.Connect(2000, TRUE) then
      LogThis('Pipe connection failed', LogFilePath, TRUE)
    else
      LogThis('Pipe connected', LogFilePath, TRUE);
  end;
  
  procedure TThreadMonitor.Execute;
  begin
    inherited;
  
    ConnectPipe;  //&lt;---throws exception here although getting "Pipe Connected"
      while not Terminated do
      begin
        for i := 0 to Length(listOfProcesses) - 1 do
        begin
          ...
          MonitorProcess(listOfProcesses[i]);
          ...
        end;
        sleep(2000);
      end;
  end;
  </code></pre>