Fastream Technologies wrote: > I had the same problem. In my case, I had to post a message before > ending the thread. There was pending messages that called GetHandle > which called AllocateHwnd()!!!
My problem still persists, sometimes the exception "Cannot attach when not detached" is raised. However I cannot imagine that exchanging WaitFor by your method can change anything basically. Probably the strange GetHandle() getter is the culprid? > > Regards, > > SZ > > ----- Original Message ----- > From: "Arno Garrels" <[EMAIL PROTECTED]> > To: "ICS support mailing" <twsocket@elists.org> > Sent: Thursday, June 22, 2006 4:20 PM > Subject: [twsocket] V6 ThreadDetach #2 > > >> I have the following problem in V6: >> >> constructor TListenThread.Create(AServer: TMtWSocketServer); >> begin >> inherited Create(True); >> FreeOnTerminate := FALSE; >> FServer := AServer; >> FServer.ThreadDetach; >> end; >> >> procedure TListenThread.Execute; >> begin >> FServer.ThreadAttach; >> FServer.Listen; >> FServer.MessageLoop; >> FServer.Close; >> FServer.ThreadDetach; >> end; >> >> procedure TForm1.btnStartClick(Sender: TObject); >> begin >> //properties of Server1 are assigned >> FListenThread := TListenThread.Create(Server1); >> FListenThread.Resume; >> end; >> >> >> procedure TForm1.btnStopClick(Sender: TObject); >> begin >> PostMessage(Server1.Handle, WM_QUIT, 0, 0); >> FListenThread.WaitFor; >> FreeAndNil(FListenThread); >> => here the Server1.Handle is not 0! >> Server1.ThreadAttach; // so raises an exception >> end; >> >> Any idea? >> >> --- >> Arno Garrels [TeamICS] >> http://www.overbyte.be/eng/overbyte/teamics.html >> >> -- >> To unsubscribe or change your settings for TWSocket mailing list >> please goto http://www.elists.org/mailman/listinfo/twsocket >> Visit our website at http://www.overbyte.be -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be