In my GUI-program I want to use function LCLIntf.AddEventHandler to handle some communication with other clients via internet.
Function AddEventHandler is declared as:
function AddEventHandler(AHandle: THandle; AFlags: dword; AEventHandler: TWaitHandleEvent;
AData: PtrInt): PEventHandler;
My question is about the 1st parameter 'AHandle': what must I use here on Windows and on Linux?
Linux:The documentation (which is hard stuff for me)
https://wiki.freepascal.org/Main_Loop_Hooks says in chapter "Pipes and Process Termination" (which my be wrong for function AddEventHandler):
For gtk/unix, use the PID to watch as AHandle.
But when I use the PID from function system.GetProcessID as parameter 'AHandle' then I get always a Message in the Console:
(unit1:4198): GLib-WARNING **: 10:25:46.429: ../../../../glib/giounix.c:410Error while getting flags for FD: Ungültiger Dateideskriptor (9)
The line number 4198 is wrong, so it does not help. The 2 German words mean "Invalid filedescriptor".
If I use instead a small number like 0..9 as parameter 'AHandle' then I do NOT get this Message. But with a high random number like 12345 I get this Message too. So I think the PID is here wrong.
Windows:When I use the PID as parameter 'AHandle' then I get always endless Messages in the Console:
[TWin32WidgetSet.AppProcessMessages] MsgWaitForMultipleObjects returned: 6
[TWin32WidgetSet.AppProcessMessages] MsgWaitForMultipleObjects returned: 6
[TWin32WidgetSet.AppProcessMessages] MsgWaitForMultipleObjects returned: 6
...
If I use instead a small number like 3 or 7..9 as parameter 'AHandle' then it works, but I don't think this is reliable.
What I want:I want a hook in the Main Loop, so that my procedure is called frequently, e.g. 10-20 times a second to handle some communication with other clients via internet.
I'm using Lazarus 2.0.10. Thanks in advance.