GG2023 0 Posted September 28 I was told the component uses message pump so guess the answer is no. I am having Thread handle is invalid (6) when I create this object in thread's constructor. The application is a service, so no forms and no messaging. Thanks. Share this post Link to post
Angus Robertson 690 Posted September 28 ICS components are widely used in Windows Services, less often in threads, really two different questions. For Windows Services, a VCL service project with SvcMgr gives you a form onto which to drop your components, and provides a message pump so they work just as if it is a GUI. ICS has a sample IcsAppMon;,dpr which has a WebSocket server component running as a Windows Service, although it uses the DDSvcMgr version ofSvcMgr which allows the application to be run as both a GUI or installed as a Windows Service, makes development and debugging much easier. Using the WebSocket Client would be no different, that is used in the sample IcsAppMonMan which talks to the server, but is only a GUI since it talks to multiple servers. Not sure why, but we don't seem to currently have any simple Windows Service samples, guess I need to add one for the next release. Angus Share this post Link to post
Olli73 8 Posted September 28 6 hours ago, GG2023 said: I am having Thread handle is invalid (6) when I create this object in thread's constructor. When you want to use the object inside a thread, then you should create it inside the thread - the constructor still runs in the main thread! Share this post Link to post
GG2023 0 Posted September 28 Thanks a lot guys, I will try to re-work this a bit... Share this post Link to post
GG2023 0 Posted October 1 Thanks a lot guys, I will try to re-work this a bit... Share this post Link to post
GG2023 0 Posted October 1 Well the socket is now being created without exceptions, but OnWSFrameRcvd never gets fired. I create the socket with NIL as an Owner. Should I somehow reference service's main DM in order to get message pump to work? Thanks. Share this post Link to post
GG2023 0 Posted October 1 Well the socket is now being created without exceptions, but OnWSFrameRcvd never gets fired. I create the socket with NIL as an Owner. Should I somehow reference service's main DM in order to get message pump to work? Thanks. Share this post Link to post
GG2023 0 Posted October 1 Or should I set MultiThreaded property to TRUE? Share this post Link to post
Angus Robertson 690 Posted October 1 You have not explained your environment, but assuming this is a Windows Service, you should have the message loop in the ServiceExecute event: procedure TIcsTcpServce.ServiceExecute(Sender: TService); begin while not Terminated do ServiceThread.ProcessRequests(TRUE); end; So there is only one thread for the main unit, just like most GUIs. Angus Share this post Link to post